refactor: migrate nested-*FieldNames get to make_get_command (part of #587)#598
Conversation
Migrate adimages/retargeting/sitelinks/feeds/clients get onto the shared make_get_command factory (net -175 lines). Extends the factory with three generic optional params: - nested_field_options: (flag, WSDL key, help) triples for nested *FieldNames projections, parsed via the existing parse_nested_field_names (which rejects a provided-but-empty CSV) and rendered between --fields and --dry-run. - ids_criteria_key: SelectionCriteria key for --ids (clients uses ClientIds). - fields_help: resource-specific --fields wording (sitelinks). The shared get_options decorator gains matching nested_options / fields_help hooks, both defaulting to current behavior so its ~15 other callers are byte-identical. Byte-identity preserved (verified against pre-migration baselines): --help option order incl. the nested-field option position and custom --fields help, --dry-run payloads incl. ClientIds and nested params, and the provided-but-empty *FieldNames UsageError. Part of #587 (Group 2 / nested *FieldNames). Deferred to a follow-up: adextensions (emits empty SelectionCriteria + Page-before-nested order), and leads/agencyclients (no --ids). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@claude @codex review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 2m 36s —— View job Review — PR #598: nested-
|
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Non-blocking follow-up to the PR #598 review (Claude): the default criteria builder only maps --ids, so extra_options that feed SelectionCriteria are silently dropped without a matching criteria_builder. Document the sharp edge for the next migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Migrate
adimages get,retargeting get,sitelinks get,feeds getandclients getonto the sharedmake_get_commandfactory (dedup epic #584). Follows PR #597 (Group 3 / criteria-limits).Net −175 lines (205 added, 380 removed).
Factory extension (three generic optional params)
nested_field_options— tuple of(flag, WSDL key, help)for nested*FieldNamesprojections (e.g.("--sitelink-field-names", "SitelinkFieldNames", "…")). Each renders aclick.optionbetween--fieldsand--dry-run(the position these commands use) and is parsed via the existingparse_nested_field_names, which rejects a provided-but-empty CSV with the sameUsageErrorthe inline code raised. Merged into the request params after the common params.ids_criteria_key(default"Ids") — SelectionCriteria key for the default--idsbuilder;clientsmaps--idstoClientIds.fields_help(default"Comma-separated field names") — resource-specific--fieldswording;sitelinksuses"Comma-separated SitelinksSet FieldNames".The shared
get_optionsdecorator (utils.py) gains matchingnested_options/fields_helphooks, both defaulting to current behavior so its ~15 other@get_optionscallers are byte-identical.adimages/retargeting(no nested fields, extra criteria) migrate with a small per-modulecriteria_builder;sitelinks/feeds/clientsuse the default builder plusnested_field_options(+ids_criteria_key/fields_helpwhere they diverge).Byte-identity (hard invariant of #587)
Verified each command against pre-migration baselines — all 21 snapshots identical:
--help(option order, the nested-field option position, the custom--fieldshelp),--dry-runpayloads (incl. theClientIdskey and 1/2/5 nested-field params), the provided-but-empty*FieldNamesUsageError, and the empty/limit cases.Tests
test_dry_run,test_api_coverage,test_comprehensive,test_read_cassettesincluded.ruff checkclean (dead imports from the removedgetbodies dropped).Scope / carve-outs (deferred follow-up)
adextensions— its inline params always emit an emptySelectionCriteriaand order*FieldNamesbeforePage; reproducing those exact wire bytes needs a quirk flag, so it's intentionally left for later rather than bandaided.leads/agencyclients— no--ids(bespoke required--turbo-page-ids/--logins+--archived); they'd need a futureinclude_ids=Falsefactory option.🤖 Generated with Claude Code