Repository navigation
Windows: cloudpin's own variables and the read-only check fold names; Wrangler's login folder per platform (#136) - #152
Merged
Merged
Conversation
…#119) `CLOUDFLARE_ACCOUNT_ID=$(cat id) wrangler deploy` dropped the variable, since guard only stops on an unknown value in a provider's identity variables (cacheInputs().env, #86), and the account variables weren't in Cloudflare's list. cloudpin then resolved the account without them while Wrangler used the unknown value. Cloudflare's identity variables are now every name in DOTENV_VARS (the account variables, CLOUDFLARE_ENV, WRANGLER_CACHE_DIR, the credentials) plus DOTENV_KEY, which makes Wrangler decrypt a .env.vault instead of .env. whoami's cache key gains names it ignores, which can only make it miss. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows variable names ignore case, and so does every guarded CLI there: Node's process.env, Wrangler's caseInsensitiveEnv proxy over its merged environment (wrangler@4.151.3, config/case-insensitive-env.ts, used by config/dot-env.ts loadDotEnv on Windows only, installed as process.env in index.ts), Go's os.Getenv and Python's upper-cased os.environ. guard handed providers a plain object, so `cloudflare_account_id=B` from the shell or an agent's line was missed by env.CLOUDFLARE_ACCOUNT_ID, as were gh_host and the rest, and the identity cache keyed on AWS_* missed aws_profile and reused another profile's identity. On win32 guard now gives the provider one upper-case key per name. When two spellings of a variable that decides the account hold different values, which one a CLI sees depends on the shell and the CLI, so the command blocks as can't tell, naming the spellings, never the values. Other variables keep the value of the first key in code-unit order, the one Node keeps when it spawns. An unknown value in either spelling blocks as before (#86). Linux and macOS are unchanged. The platform is injectable through GuardDeps for tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cache wrapper computed its watched files from the unfolded environment, so with a lowercase azure_config_dir it watched the default ~/.azure folder, and an `az account set` in the named folder kept reusing the old identity for up to five minutes. It now gets the same folded environment as resolve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New tests for what the Windows variable-name fold (#119) left out, each with a Linux control and the platform given to guard, so both sides run on any OS: - the user's lowercase cloudpin_env and cloudpin_branch pick the environment in the agent hook on win32, while the agent's own assignment, export or unset of them in any spelling still doesn't count; - a lowercase cloudpin_confirm or cloudpin_skip in a terminal on win32; - a lowercase aws_config_file next to an alias file makes a protected environment ask on win32; - a lowercase name inside Wrangler's .env folds by the given platform; - the identity cache watches Wrangler's login file where Wrangler writes it on each platform (%APPDATA%\xdg.config on Windows). Before the fix, 11 fail and the 2 Linux-only tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…136) guard folds the command's variable names before it reads CLOUDPIN_SKIP and CLOUDPIN_CONFIRM, so a user's lowercase cloudpin_confirm or cloudpin_skip counts in a terminal on Windows, as Windows itself reads them. Both still count in shell mode only, so an agent can't use either in any spelling. Linux and macOS are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isReadOnly decides whether a protected environment asks for confirmation, and for aws it looks for an alias file next to AWS_CONFIG_FILE. It got the unfolded environment, so on Windows a lowercase aws_config_file was missed and an aliased `aws s3 ls` skipped the question. guard now passes the environment with Windows names folded. Linux and macOS are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The command context now carries the platform the command runs on, and guard passes its own. The Cloudflare provider hands it to wranglerDotenv, which folds the names inside .env files on Windows only, as Wrangler does; it used to fold by process.platform, so the Windows behaviour was tested only on a Windows run and the Linux one only elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cOS (#136) The cached `wrangler whoami` is keyed on Wrangler's login file, but cloudpin watched ~/.config/.wrangler on every platform. Wrangler's XDG config folder is %APPDATA%\xdg.config on Windows and ~/Library/Preferences on macOS (workers-utils getGlobalConfigPath and xdgConfig, unchanged from wrangler@4.151.3 to the current main), so a re-login there didn't drop the 5-minute cache. cacheInputs now takes the platform (guard passes its own; it defaults to this process's), and an empty XDG_CONFIG_HOME counts as unset, as in Wrangler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pure move, no behaviour change: USER_ONLY_VARS and envFor, with their doc comments, go verbatim from src/shellwords.ts (over its size limit) into the new src/user-env.ts, which imports only the Invocation type from shellwords.ts. The importers (hooks/agents.ts, explain.ts and three tests) import envFor from user-env.ts directly; nothing else used it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents still can't set them (#136) guard folds the command's variable names before findConfig, so a user's lowercase cloudpin_env or cloudpin_branch picks the environment in the agent hook on Windows, as the real process reads it there. In the same change envFor's user-only check folds the names on Windows, so an agent's inline, exported, plain or unset cloudpin_env (any spelling) is still ignored, as CLOUDPIN_ENV=... is today. The hook and explain pass the platform guard is given. Linux and macOS are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every conflicted file takes main's version; #152's behaviour is ported onto main's code in the commits that follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's cacheInputs (#103) watches each Wrangler folder's config/ directory, which holds every profile's login, and its profile bindings file, rather than config/default.toml alone, so the test expects those per platform. On win32 Wrangler's home is USERPROFILE (os.homedir), so the XDG_CONFIG_HOME case sets it next to HOME. The folders expected per platform are unchanged. Still failing: cacheInputs ignores the platform it is given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…136) guard folds the command's variable names once, before anything reads them, and the terminal's CLOUDPIN_SKIP and CLOUDPIN_CONFIRM come from that folded environment, so a lowercase cloudpin_confirm counts on win32 as it does for the shell. Agents still can't confirm or skip in any spelling; other platforms are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isReadOnly reads AWS_CONFIG_FILE to find an AWS CLI alias file; on win32 a lowercase aws_config_file is the same variable for the AWS CLI, so a protected `aws s3 ls` next to an alias file now asks there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CommandContext carries the platform the command runs on and cacheInputs takes it as a second argument, both from guard's deps.platform, so a provider's per-platform behaviour can be tested on any host. Without it they default to this process's platform, as before. CONTRIBUTING says to read it there, never process.platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en (#136) wranglerConfigDirs (#103) already knows Wrangler's per-platform login folder: %APPDATA%\xdg.config\.wrangler on Windows, ~/Library/Preferences/.wrangler on macOS, ~/.config/.wrangler elsewhere, XDG_CONFIG_HOME first when non-empty. cacheInputs and resolve now hand it, the .env reader and the profile lookup the platform they are given instead of this process's, so the identity cache and .env name folding are right for the command and testable on any host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents still can't set them (#136) guard hands findConfig the folded environment, so a user's lowercase cloudpin_env or cloudpin_branch picks the environment on win32, as Windows reads it. In the same change envFor's user-only check folds the name on win32 (the platform guard is given, passed by the hook and explain), so an agent's cloudpin_env=..., export, $env: assignment or unset, in any spelling, still doesn't count and can't undo the user's choice. Linux and macOS are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #136. Target: 1.3.0. This is a draft stacked on #135 (base
fix/119-cloudflare-account-vars), because it builds on #135'sfoldEnvNames. Merge #135 first, then retarget this PR to main. The CHANGELOG and ROADMAP lines get added at that point.What changes (Windows only; Linux and macOS controls unchanged)
cloudpin's own variables are case-insensitive in hook mode.
cloudpin_env,cloudpin_branch,cloudpin_confirmorcloudpin_skipset by the user now counts, as it does for the real process. guard folds the environment beforefindConfig.CLOUDPIN_ENV/CLOUDPIN_BRANCHin any spelling. On win32,envFor's user-only check folds the name, and the read fold and the check fold land in the same commit (2c4e82a).The read-only check gets the folded environment, so on Windows a lowercase
aws_config_filemakes a protectedaws s3 lsask.Wrangler's login folder. The identity cache now watches the folder Wrangler really uses:
%APPDATA%\xdg.config\.wrangler~/Library/Preferences/.wrangler~/.config/.wranglerXDG_CONFIG_HOMEwins on every platform.Source: cloudflare/workers-sdk
packages/workers-utils/src/xdg-app-paths.tsandglobal-wrangler-config-path.ts. Before, a re-login on Windows or macOS didn't drop the 5-minute whoami cache.Providers get the platform guard is given (
CommandContext.platform,cacheInputs(env, platform)), sowranglerDotenv's fold of.envnames is tested for both platforms on any host.src/shellwords.tswas over the 5,000-token file cap, soUSER_ONLY_VARSandenvFormoved to the newsrc/user-env.tsfirst, in a pure move (5322307). A script proved it verbatim, its one-character controls fail as they should, and the test counts are unchanged.Tests
The tests are in the new files
test/windows-case-gaps.test.tsandtest/wrangler-login-folder.test.ts. They were committed failing first: 11 of the 13 failed, and the two Linux-only ones passed. Typecheck passes. Full suite: 52 files, 1265 passed, 8 skipped.cloudpin_env=would be accepted (2 tests failed), and removing thefindConfigfold (3 failed). The files were restored afterwards.Left open
envFor'sname in basecheck for plain assignments, andunsetof non-user variables, still compare names case-sensitively.🤖 Generated with Claude Code