Repository navigation
fix: explain account-or-zone scope and reject an empty --zone - #422
khoinguyenpham04 wants to merge 8 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 — No problems found. The generator change, the Findings: 2 info The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔒 Security: 💬 1 infoNo security problems. Not every regenerated file was opened. Recommendation: 💬 Optional Nits
View full reviewNo security problems found. With the new validation, an empty 📋 Code Quality: 💬 1 infoNo defects. Most of the regenerated command files were not read one by one. Recommendation: 💬 Optional Nits
View full reviewNo problems found in the generator ( ✅ All other checks passed🚀 Release: ✅ LGTMRisk: low. Both changesets describe their user-facing changes. 📖 AGENTS.md: ✅ LGTMThe change follows the repository conventions. Generated output comes from the generator plugin, and each user-facing change has a changeset. ⚡ Performance: ✅ LGTMNo performance concerns. The change adds help text and a check on the flag value. 📝 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.
|
clanky review |
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.