fix(generator): preserve nonexclusive gcloud update groups - #5343
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe scraper now preserves documented nonexclusive choices within choice groups. A new gcloud Kafka fixture and regression test validate combinations of CPU, memory, and mTLS CA pool flags. ChangesGcloud choice preservation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Possibly related PRs
Merge Risk: ⚪ Minimal · up to The scraper preserves valid combinations of Kafka update settings while retaining mutually exclusive CA-pool flags. The focused validation and formatting checks pass, leaving no concrete merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit found a choice in the CLI, Comment |
There was a problem hiding this comment.
Claude Review
This PR fixes GcloudCliScraper.PreserveDocumentedChoices so a documented nonexclusive "at least one" FLAGS group (with a nested mutually-exclusive sub-choice) is preserved even when the gcloud SYNOPSIS parser flattens it into a single fully-exclusive choice, fixing false rejection of independent managed-kafka clusters update flags like --cpu combined with --mtls-ca-pools. I traced the removed group.IsChoice ? null : ... guard through the merge logic and confirmed the replacement match is safely scoped (exact PropertyNames set equality against the single already-matched documented constraint), verified the new captured-SDK fixture and generated-validation test exercise real compiled option types against the correct at-least-one/at-most-one semantics, and confirmed no production generated options file was hand-edited, consistent with repo policy of deferring regeneration to a separate PR."}
Review evidence
tools/ModularPipelines.OptionsGenerator/src/ModularPipelines.OptionsGenerator/Scrapers/Cli/GcloudCliScraper.cs: Traced PreserveDocumentedChoices end-to-end: removing the group.IsChoice ? null : ... guard lets a documented nonexclusive AtLeastOne candidate (FLAGS section) fully replace a SYNOPSIS-derived group even when the SYNOPSIS parser mis-flattened it into a mutually-exclusive choice. Verified the match still requires exact PropertyNames set equality against documented, which is itself scoped to the single previously-matched constraint (via ReconcileRequiredSynopsisChoices), so the loosened guard cannot spuriously reclassify unrelated exclusive groups elsewhere.
tools/ModularPipelines.OptionsGenerator/src/ModularPipelines.OptionsGenerator.Tests/Generators/GcloudNestedSynopsisValidationTests.cs: New Kafka test compiles a real generated options type and runs Validator.TryValidateObject, not just a hand-checked model tree. Walked all 9 asserted combinations against expected at-least-one/nested-at-most-one semantics (Cpu+MtlsCaPools valid, empty invalid, ClearMtlsCaPools+MtlsCaPools together invalid) and all match the documented FLAGS constraint correctly.
tools/ModularPipelines.OptionsGenerator/src/ModularPipelines.OptionsGenerator.Tests/Fixtures/Gcloud/585.0.0/gcloud-managed-kafka-clusters-update.txt: New captured SDK 585 fixture; SYNOPSIS flattens 9 independent settings plus --clear-mtls-ca-pools into one bracketed alternative vs. --mtls-ca-pools, while REQUIRED FLAGS documents the true nested at-least-one/at-most-one shape the fix is designed to preserve.
No actionable findings.
Optional follow-up notes
No production generated file (e.g. GcloudManagedKafkaClustersUpdateOptions.Generated.cs) is regenerated in this PR — it currently has no options at all for this command, from an older captured SDK version. This is consistent with AGENTS.md's split of generator fixes from regeneration PRs and the PR body's stated plan for a follow-up regeneration; just confirming it's intentional, not an oversight.
This is the second narrowly-scoped patch in a row to the same SYNOPSIS-vs-FLAGS reconciliation logic in GcloudCliScraper (previous: #5342 'preserve documented gcloud branch optionality', immediately prior commit on main). As more gcloud quirks surface, consider consolidating PreserveDocumentedChoices/RestoreFlattenedDocumentedChoices into a single documented algorithm (e.g. a small state machine or documented invariant list) rather than continuing to add one-off guard removals/conditions, since each new edge case increases the risk of subtly interacting with earlier ones and makes the intent harder to verify by inspection alone.
No prior human/bot review findings exist yet to verify as addressed (Codex review was still 'Running' at capture time); nothing outstanding to reconcile.
A valid
gcloud managed-kafka clusters update --cpu=3 --mtls-ca-pools=...is rejected because its flattened SYNOPSIS makes independent update settings appear mutually exclusive. SDK 585 FLAGS instead documents an "at least one" group with a nested "at most one" choice for clearing versus replacing CA pools.Preserve the complete matching documented nonexclusive group even when the SYNOPSIS parser classified it as a choice. This retains both independent settings and nested exclusions without command-specific rules.
The captured SDK regression fails before the fix and passes after it. Its nine combinations cover CPU/CA-pool updates, individual settings, empty input, and conflicting CA-pool flags. All 19 focused Google generated-validator tests and formatting pass. Full CI passes all 3,380 generator tests. Claude, Codex, CodeRabbit, and CodeFactor are clear. All CodeQL checks pass; no outstanding findings remain.
Related: #5339. Generation run 35682446460 was cancelled and verified complete before publishing known defective output. Fresh latest-main regeneration follows this source fix; the Google acceptance issues remain open until the replacement passes actual integration CI.