Skip to content

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

Merged
CydeWeys merged 1 commit into
google:masterfrom
CydeWeys:update-list-upsert
Oct 14, 2026
Merged

CydeWeys merged 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.

@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)

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@CydeWeys made 2 comments.
Reviewable status: 6 of 14 files reviewed, 2 unresolved discussions (waiting on gbrodman).


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

Previously, gbrodman wrote…

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

Done.


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

Previously, gbrodman wrote…

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

Done.

@CydeWeys CydeWeys left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

PTAL

@CydeWeys made 1 comment.
Reviewable status: 6 of 14 files reviewed, 2 unresolved discussions (waiting on gbrodman).

@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 8 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on CydeWeys).

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 enabled auto-merge October 14, 2026 21:42
@CydeWeys
CydeWeys added this pull request to the merge queue Oct 14, 2026
Merged via the queue into google:master with commit 19b20b7 Oct 14, 2026
16 checks passed
@CydeWeys
CydeWeys deleted the update-list-upsert branch October 14, 2026 23:11
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