Repository navigation
Prefer CLOUDFLARE_ACCOUNT_ID to the configured accountId - #17205
Conversation
🦋 Changeset detectedLatest commit: 80e5911 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
I'm Bonk, and I've done a quick review of your PR. Updates shared account precedence, preserving Wrangler behavior.
|
…loudflare Vite and Vitest plugins and in `cf dev`
66ffa8d to
80788b8
Compare
80788b8 to
0f22371
Compare
0f22371 to
aa970f1
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers |
There was a problem hiding this comment.
Superseded by the review of
80e5911f.
This review, of aa970f1d
✅ Approved — The change does what it says: CLOUDFLARE_ACCOUNT_ID now wins over the configured accountId in the Vite and Vitest plugins and in cf dev, Wrangler keeps its old order, and tests cover both. No problems found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
This changes which Cloudflare account is used when CLOUDFLARE_ACCOUNT_ID and the config disagree. The changesets explain this clearly, and new tests cover both the account order and the .env reload.
🔒 Security: ✅ LGTM
I found no security issues. The remote-bindings cache key is hashed, so it holds no credentials.
📖 AGENTS.md: ✅ LGTM
The packages/workers-auth/AGENTS.md update matches the new descriptor option.
📋 Code Quality: ✅ LGTM
I found no problems in the account lookup order, the .env reload or the auth cache key.
- Account lookup order (
packages/workers-auth/src/core/factory.ts):preferConfiguredAccountIdis off unless set, and only the Wrangler descriptor turns it on. Socfand the plugins readCLOUDFLARE_ACCOUNT_IDfirst, and Wrangler still reads the configuredaccount_idfirst. Because the environment variable is only read when it is needed, an invalid value in it does not break Wrangler commands that have an account configured. .envreload (packages/vite-plugin-cloudflare/src/plugin-config.ts): on reload, the plugin only removes values it copied from.envitself and that are still unchanged, so variables set in the shell are kept. The tracking map covers the whole process becauseprocess.envdoes; the author explains this in the discussion.- Auth cache (
context.ts,auth.ts): the cached auth is rebuilt when the profile orCLOUDFLARE_API_TOKENchanges. The remote-bindings cache key includes the account and token variables and is hashed, so no secret is stored in it.
⚡ Performance: ✅ LGTM
The new work is small. The .env cleanup loops once over a small map that is cleared on every reload, and the cache key is hashed once per call. Neither has a noticeable cost.
📝 Documentation: ✅ LGTM
The changesets describe the new precedence and the .env reload behaviour accurately.
Reviewed commit: aa970f1d
There was a problem hiding this comment.
✅ Approved — With this change, CLOUDFLARE_ACCOUNT_ID takes precedence over the configured accountId in the Vite and Vitest plugins and in cf dev, and Wrangler keeps its existing order. The updates to context.ts and auth.spec.ts since the last review are correct.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
This changes which Cloudflare account remote bindings and Vite plugin tunnels use when CLOUDFLARE_ACCOUNT_ID and the configuration disagree. The changesets document this clearly, and tests cover both the account precedence and the .env reload.
🔒 Security: ✅ LGTM
No security issues. The token is hashed in the cache key, so the key does not contain the secret.
📖 AGENTS.md: ✅ LGTM
The update to packages/workers-auth/AGENTS.md matches the new descriptor option.
📋 Code Quality: ✅ LGTM
Only context.ts and auth.spec.ts changed since the last review, and both are correct.
- Cached auth (
context.ts:76-91):getCloudflareAuthbuilds a new auth instance when the profile changes. It also does this whenCLOUDFLARE_API_TOKENchanges. It keeps the value ofCLOUDFLARE_API_TOKENfrom when the instance was created, which answers the question in the discussion about why the token is stored.getAPIToken()can't detect a change, because it returns the current token, or the stored OAuth token when the variable isn't set. The new comment at lines 42-46 explains this. - Tests (
auth.spec.ts): the new tests restore the environment variables they change. They check that the auth is rebuilt when the token changes, and that the token is hashed in the remote-bindings cache key rather than stored as plain text.
Account precedence in factory.ts and the .env cleanup in plugin-config.ts are unchanged since the last review, and both are still correct.
⚡ Performance: ✅ LGTM
The new token comparison is a single string check per call, so it adds no noticeable cost.
📝 Documentation: ✅ LGTM
The changesets describe the new account precedence and the .env reload behaviour accurately.
Reviewed commit: 80e5911f
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Prefer
CLOUDFLARE_ACCOUNT_IDto the configuredaccountIdin the Cloudflare Vite and Vitest plugins and incf devWhen resolving an account for remote bindings, and for tunnels in the Vite plugin, the plugins and
cf devused theaccountIdincloudflare.config.tseven whenCLOUDFLARE_ACCOUNT_IDwas set to a different account. This was the reverse of othercfcommands, where the environment variable takes precedence.CLOUDFLARE_ACCOUNT_IDnow takes precedence there too.wranglercommands, and Vitest plugin projects that use a Wrangler configuration file, are unchanged: the configuredaccount_idstill takes precedence.A picture of a cute animal (not mandatory, but encouraged)