Repository navigation
fix: explain account-or-zone scope and reject an empty --zone - #422
khoinguyenpham04 wants to merge 7 commits into
Conversation
An empty --zone switched account-or-zone commands to zone scope with no zone ID, so --dry-run previewed /zones//… and a real run fell back to CLOUDFLARE_ZONE_ID. Validate the global flag the way --mode is validated.
The 124 commands generated from /{account_or_zone}/{account_or_zone_id}
paths run against the account unless --zone is passed, but their help
only repeated the API description. Add one line to their usage saying so,
including that CLOUDFLARE_ZONE_ID doesn't switch the scope, and
regenerate.
…ands Pin the rest of cloudflare#33's expected behaviour: CLOUDFLARE_ZONE_ID alone keeps the account route, and a command fails before any request when no account can be picked or the --zone name isn't found. The route tests now record which scope each request went to.
"Doesn't switch the scope" sat oddly above the global --zone line, which says the flag overrides CLOUDFLARE_ZONE_ID. These commands never read it, so say that. The architecture note now says dry-run keeps a zone name as given, since it makes no request.
Check the global flag on a zone-only command (-z, --zone=, --no-zone and a repeated --zone), show that a zone name needs an account too, and stop asserting on @cloudflare/workers-auth's wording.
commit: |
|
💬 Approved with comments — The generator, runtime validation and regenerated commands look correct and are tested. One suggestion: the changeset should mention the change to how pass-through Findings: 1 suggestion The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 🚀 Release: 💬 1 suggestionThe changeset leaves out a pass-through behaviour change Recommendation: 💬 Optional Nits
View full review
✅ All other checks passed🔒 Security: ✅ LGTMNo security problems found. With the new validation, an empty 📖 AGENTS.md: ✅ LGTMThe change follows the repository conventions. The generated output was produced by changing the generator plugin, not by editing 📋 Code Quality: ✅ LGTMNo problems found in the generator changes ( ⚡ Performance: ✅ LGTMNo performance concerns. The changes add help text and a check on the flag value at startup. 📝 Documentation: ✅ LGTMThe Reviewed commit: |
|
clanky review |
Upstream moved GLOBAL_OPTIONS from src/index.ts to src/lib/global-options.ts, so the --zone coerce moves with it. Regenerating at the new OpenAPI pin (e2b8c60b0222) changes nothing: the same 124 account-or-zone commands carry the scope help line.
Closes #33.
Commands generated from
/{account_or_zone}/{account_or_zone_id}paths alreadyrun against the account by default, switch to a zone with
--zone, and showthe chosen scope in
--dry-run. This PR covers the rest of the issue:--zonewithout a value now fails. Before, it switchedto zone scope with no zone ID.
CLOUDFLARE_ZONE_IDon its own keeps the account route. A commandfails before any request when no account can be picked (a zone name needs
one too) or the
--zonename isn't found.Before and after
1. Help explains which scope runs
Before, help only repeated the API description:
After, two lines say how the scope is picked:
2.
--zonewithout a value failsBefore, the command switched to zone scope with an empty zone ID, so the
preview shows
zones//:After, it stops with an error:
Notes
CLOUDFLARE_ZONE_ID, so a variable set for zone-onlycommands can't quietly redirect them.
--zoneis now validated like--mode: an empty value,--no-zone, or a repeated--zonefails. An empty value used to fall backto
CLOUDFLARE_ZONE_IDonly because an empty string is falsy, so this shipsas a patch.
--before arguments that clash with cf'sglobal flags.
cf containers ssh <id> ls -znow fails instead of silentlydropping the
-z.--dry-runmakes no requests, so it doesn't resolve a zone name:--zone example.com --dry-runpreviews/zones/example.com/…, as zone-onlycommands already do.
@cloudflare/workers-authand doesn'tmention
--zone. I've left it as is.