Skip to content

feat(sidekick/surfer): prefix nested message flag names with parent names#5805

Merged
jameslynnwu merged 1 commit into
googleapis:mainfrom
jameslynnwu:fix-librarian-issue-5511-20260501
May 7, 2026
Merged

feat(sidekick/surfer): prefix nested message flag names with parent names#5805
jameslynnwu merged 1 commit into
googleapis:mainfrom
jameslynnwu:fix-librarian-issue-5511-20260501

Conversation

@jameslynnwu
Copy link
Copy Markdown
Contributor

Surfer now prepends parent field names to generated gcloud flag names for fields inside nested messages, preventing collisions and matching gen_sfc behavior.

The new logic derives the flag name from the API field path and applies rules to strip request message names and explicit body field names, avoiding redundant prefixes. This logic is encapsulated in a new deriveArgName helper function.

Fixes #5511

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new logic for deriving argument flag names in the argumentBuilder. The deriveArgName method ensures that nested fields have unique and contextual names by prepending parent field names while stripping redundant API request boilerplate, such as request message names or explicit body field names. The changes include the implementation in argument_builder.go, corresponding unit tests in argument_builder_test.go, and updated expected output in several YAML test data files. I have no feedback to provide.

@jameslynnwu jameslynnwu marked this pull request as ready for review May 4, 2026 20:58
@jameslynnwu jameslynnwu requested review from a team as code owners May 4, 2026 20:58
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
@sarahheacock sarahheacock added the surfer Issues related to the surfer project (https://github.com/googleapis/librarian/issues/2375) label May 5, 2026
@jameslynnwu jameslynnwu marked this pull request as draft May 6, 2026 15:22
@jameslynnwu jameslynnwu force-pushed the fix-librarian-issue-5511-20260501 branch 4 times, most recently from 0ec17b3 to 232f2d7 Compare May 6, 2026 17:54
@jameslynnwu jameslynnwu marked this pull request as ready for review May 6, 2026 17:55
@jameslynnwu jameslynnwu force-pushed the fix-librarian-issue-5511-20260501 branch from 232f2d7 to 618120d Compare May 6, 2026 17:59
@jameslynnwu jameslynnwu requested a review from sarahheacock May 6, 2026 18:03
@jameslynnwu jameslynnwu force-pushed the fix-librarian-issue-5511-20260501 branch from 618120d to cadef8e Compare May 6, 2026 18:44
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/argument_builder.go Outdated
Comment thread internal/sidekick/surfer/command_builder.go Outdated
Comment thread internal/sidekick/surfer/command_builder.go
…ames

Surfer now prepends parent field names to generated gcloud flag names for
fields inside nested messages, preventing collisions and matching gen_sfc
behavior.

To support this robustly, the internal generator representation was
refactored to represent nested field paths using rich api.Field descriptors
instead of raw string JSON names. This decoupled representation allows the
generator to calculate CLI flag names (using snake_case proto Names) and
API wire payload paths (using camelCase JSONNames) independently and cleanly,
solving a latent bug where custom json_name options would incorrectly leak
into CLI flags.

Fixes googleapis#5511
@jameslynnwu jameslynnwu force-pushed the fix-librarian-issue-5511-20260501 branch from cadef8e to 019b2bf Compare May 7, 2026 00:38
@jameslynnwu jameslynnwu merged commit aeab2bf into googleapis:main May 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

surfer Issues related to the surfer project (https://github.com/googleapis/librarian/issues/2375)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

surfer: enable flag naming prefixes

2 participants