Skip to content

Add --upsert flag to update list commands - #3248

Open
CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:update-list-upsert
Open

CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:update-list-upsert

Conversation

@CydeWeys

@CydeWeys CydeWeys commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Add --upsert (-u) flag to UpdatePremiumListCommand and UpdateReservedListCommand so that missing premium and reserved lists are created automatically when --upsert is specified, while still failing when --upsert is omitted and the list does not exist.

Allow CurrencyUnit to be nullable in PremiumListUtils.parseToPremiumList() so that PremiumList.createFromLine() infers the currency unit from the input lines when currency is unset, and use this in UpdatePremiumListCommand when creating a new list via --upsert. Also fix the mixed-currency example in config/files/premium/example.txt.

Also propagate exceptions from CreateOrUpdatePremiumListCommand.execute() and CreateOrUpdateReservedListCommand.execute() instead of catching and swallowing Throwable, and validate non-empty and parseable input data in CreatePremiumListCommand.prompt(). Add comprehensive unit tests across PremiumListUtilsTest and the create/update list command test suites.

BUG=http://b/569977604


This change is Reviewable

@CydeWeys

CydeWeys commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

I figured this approach was better than trying to make the shell scripts have to parse the text output of the create command determine if they needed to call the update command.

Add --upsert (-u) flag to UpdatePremiumListCommand and
UpdateReservedListCommand so that missing premium and reserved lists are
created automatically when --upsert is specified, while still failing
when --upsert is omitted and the list does not exist.

Allow CurrencyUnit to be nullable in PremiumListUtils.parseToPremiumList()
so that PremiumList.createFromLine() infers the currency unit from the
input lines when currency is unset, and use this in
UpdatePremiumListCommand when creating a new list via --upsert. Also fix
the mixed-currency example in config/files/premium/example.txt.

Also propagate exceptions from CreateOrUpdatePremiumListCommand.execute()
and CreateOrUpdateReservedListCommand.execute() instead of catching and
swallowing Throwable, and validate non-empty and parseable input data in
CreatePremiumListCommand.prompt(). Add comprehensive unit tests across
PremiumListUtilsTest and the create/update list command test suites.

BUG=http://b/569977604
@CydeWeys
CydeWeys force-pushed the update-list-upsert branch from d4756db to c3aea0f Compare October 9, 2026 17:23

@gbrodman gbrodman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbrodman reviewed 13 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on CydeWeys).


core/src/main/java/google/registry/tools/CreatePremiumListCommand.java line 60 at r1 (raw file):

    }
    inputData = Files.readAllLines(inputFile, UTF_8);
    checkArgument(!inputData.isEmpty(), "New premium list data cannot be empty");

instead of checking here, as long as we're parsing the list anyway, we should parse the list then check to make sure there are at least some lines -- this would falsely succeed on a file with only a comment


core/src/main/java/google/registry/tools/UpdateReservedListCommand.java line 52 at r1 (raw file):

    List<String> allLines = Files.readAllLines(input, UTF_8);
    if (existingReservedList.isEmpty()) {
      newChange = true;

i think we also need to make sure the name is valid (though we cannot guarantee the TLD exists yet)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants