cmd/snapd/cli: search all given sections instead of only the last one - #17414
Open
Basit-Balogun10 wants to merge 1 commit into
Open
cmd/snapd/cli: search all given sections instead of only the last one#17414Basit-Balogun10 wants to merge 1 commit into
Basit-Balogun10 wants to merge 1 commit into
Conversation
snap find --section=games --section=social silently searched only "social", discarding "games" with no error - Section is a scalar field, so repeated flags just overwrote each other. The store's /v2/find "category" parameter (section is an alias for it) already accepts a comma-separated list and matches any of them - confirmed directly against the real store. Make SectionName implement flags.Unmarshaler so repeated --section flags, and comma-separated values within a single occurrence, all flatten into one combined comma-joined value instead of overwriting; validate each requested section individually against the known list and list all unrecognized ones, not just the first. No daemon or client changes needed, since the comma-joined string flows through the existing Section field unchanged. Fixes: LP#1986425
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
snap find --section=games --section=socialsilently searched onlysocial, discardinggameswith no error.
Sectionis a scalar field on the CLI side (cmd_find.go), so repeated flags justoverwrote each other via
go-flags' default behavior.The store's
/v2/findcategoryparameter (whichsectionis an alias for) already accepts acomma-separated list and matches any of them (I also confirmed directly against the real store).
So we're basically making
SectionNameimplementflags.Unmarshalerso repeated--sectionflags accumulate into one comma-separated value instead of overwriting, and then validate each requested section individually against the known list.BEFORE (MULTIPLE SECTIONS SEARCH):
AFTER (MULTIPLE SECTIONS SEARCH):
BEFORE (INVALID SECTION NAMES):
AFTER (INVALID SECTION NAMES):
AI assistance: Claude Code helped diagnose and validate this.
Fixes: LP#1986425