Skip to content

Vercel: deploy, pull and dev check the link of the folder they name (#147) - #150

Merged
paureis merged 7 commits into
mainfrom
fix/147-vercel-deploy-dir
Nov 4, 2026
Merged

paureis merged 7 commits into
mainfrom
fix/147-vercel-deploy-dir

Conversation

@paureis

@paureis paureis commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #147. Target: 1.3.0.

The bug

vercel deploy <dir> and a bare vercel <dir> link and deploy the project in <dir>, but cloudpin read .vercel/project.json only from --cwd or the current folder. If sub/ was linked to another team, vercel deploy sub passed the pin and deployed there. vercel pull <dir> (which downloads env vars) and vercel dev <dir> work the same way.

The fix

  • A split first, with no behaviour change (1b6884f). Argument parsing moves from src/providers/vercel.ts to the new src/providers/vercel-args.ts, because vercel.ts would otherwise go over the 5,000-token file cap. A script checked that the moved block is verbatim, and its control (one changed character) fails as it should. The test counts are unchanged.
  • A generic parser (b85a367). mainParse becomes argParse(args, spec, permissive): arg 5.0.0 with the globals plus a command's own options.
  • The fix (c8ae82a). linkDirs returns the folders whose link a command acts on, and resolve takes the union of their linked teams. VERCEL_ORG_ID still overrides all of them, and the scope stays with the folder the command runs in. Here is what each command links in vercel 50.35 (sources are in the code comments):
    • deploy and deploy init: the first path after the command, resolved against --cwd, and only when it is a directory, as validatePaths requires. A path Vercel refuses deploys nothing, so the base folder is read instead.
    • A first word that isn't a command: Vercel runs vercel-<word> in the base folder if that extension exists, and otherwise deploys the word as a path. Both folders count, because adding a check is the safe reading.
    • pull and dev: their path argument. deploy continue links the base folder.

Tests

The tests are in the new file test/vercel-deploy-dir.test.ts, 56 of them. They were committed failing first (30 of the first 52 failed) and include guard-level wrong-pin controls. Typecheck passes. Full suite: 53 files, 1444 passed, 8 skipped.

  • The builder ran 16 mutations: 15 were caught, and one survived. That one changes nothing a user could observe: deploy continue already requires --id, which the default deploy parse rejects either way.
  • I ran two more myself. With no path lookup, 32 tests fail. Counting only the target folder for a bare word makes 1 fail. The files were restored afterwards.

Left open

  • With experimental services enabled in a parent project, vercel dev links that project root instead of the folder.
  • guidance and metrics are commands only when their feature flags are set. Reading them as paths only adds checks.
  • An existing Vercel: --scope beats --team, and a scope in vercel.json picks the team #127 test, "prefers vercel.json over now.json", may not match Vercel 50.35, which reports conflicting config files when both exist.

🤖 Generated with Claude Code

Added when merging (2026-11-04)

A review found that a folder known only at run time got through: vercel deploy "$D" read the current folder, and vercel pull "$D" and dev "$D" read a folder with no link, so nothing was compared. It now stops as "can't tell" (bf53a6a), tested in test/vercel-dynamic-dir.test.ts: 43 of its 100 tests failed before the fix, and removing each part of it turns tests red. npm run typecheck exit 0; npx vitest run: 2874 passed, 19 skipped.

Still open, for #163: a glob or brace in the folder word (vercel deploy su*) reaches cloudpin unexpanded, so the current folder's link is read.

paureis and others added 5 commits October 24, 2026 22:40
…e given (#147)

Failing on its own: cloudpin reads .vercel/project.json only from --cwd or the
folder the command runs in, so `vercel deploy sub` with sub linked to another
team passes a pin it should fail. Covers deploy (explicit, bare word, flags
before the path, deploy init), --cwd, pull and dev, with controls for known
command words, a path Vercel refuses, and the scope staying with the folder
the command runs in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pure move, so the #147 fix fits under the file-size cap: the global flag
tables, HELP_COMMANDS, mainParse and splitShortGroups, with their comments,
move verbatim to src/providers/vercel-args.ts. vercel.ts imports the three
names it uses. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… does (#147)

mainParse becomes argParse(args, spec, permissive) with the global options
and permissive mode, as before. Commands parse their own options merged with
the globals and not permissively, where an unknown flag is an error; the
deploy-path fix needs that. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…147)

vercel deploy <dir>, a bare vercel <dir>, deploy init <dir>, pull <dir> and
dev <dir> link and act on the project in <dir>, but cloudpin read the link
only from --cwd or the folder the command runs in, so a folder linked to
another team passed a pin it should fail.

linkDirs reads each command the way vercel 50.35 does: the path positional
after the command's own options, resolved against the folder after --cwd.
Deploy falls back to that folder when Vercel would refuse the path (missing,
a file, a symlink), since nothing deploys. A first word that is no Vercel
command may run an extension vercel-<word> in the folder instead of a
deploy, so both folders' links count there. The scope still comes only from
the local config in the folder the command runs in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unknown flag after the deploy path, deploy init's own options, and a
folder named dev beside `vercel dev dev`: each case fails if the command's
strict parse turns permissive, deploy init parses with the wrong options,
or the second "dev" is read as a folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paureis and others added 2 commits November 4, 2026 18:29
Since #147 a positional word can name the folder whose link picks the team,
but dynamicTarget only reads targetFlags, and linkDirs took the marker as a
missing folder: `vercel deploy "$D"` and `vercel "$D"` read the folder they
run in, and `vercel pull "$D"` and `vercel dev "$D"` read a folder named after
the marker, with no link at all. All were allowed; pull and dev also when the
folder they run in was linked to the wrong team.

linkDirs now returns undefined when the word it would read as the folder, or
the first word (which may be any command), holds a dynamic marker, also after
"--", where dynamicTarget stops reading. resolve turns that into a can't tell
with its own fix, so Resolution's error gains an optional `fix`. VERCEL_ORG_ID
is still read first, since Vercel then reads no link. A word that isn't the
folder (`ls "$D"`, `--meta "k=$V"`, a second path) still passes, and a variable
set earlier in the line reads the folder it names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis marked this pull request as ready for review November 4, 2026 23:38
@paureis
paureis merged commit e5a2d44 into main Nov 4, 2026
5 checks passed
paureis added a commit that referenced this pull request Nov 4, 2026
#147's lines were missed when #150 merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paureis added a commit that referenced this pull request Nov 4, 2026
…o longer exempt the command (#153, items 1-3) (#158)

* Test: help flags that kubectl/helm plugins, pflag value flags and yargs booleans do not stop (#153)

Failing tests for #153 items 1 to 3, with guard-level wrong-pin controls:
kubectl and helm plugins given --help, a pflag value flag that takes
--help as its value (gh, kubectl, helm), and wrangler's --help false,
-h false and --no-help. Controls show supabase and wrangler value flags
never take --help, and real help stays exempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kubectl/helm: exempt --help only for built-in commands, not plugins (#153)

kubectl runs kubectl-<name> from PATH when the first word is not a
command, and kubectl-create-<x> when <x> right after `create` is not a
built-in subcommand name; helm plugins are commands with
DisableFlagParsing. Either way the plugin gets --help and may act on the
cluster, so --help now exempts only built-in commands (kubectl 1.36.1,
helm v3.22.1 and v4.3.1 source).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* gh, kubectl, helm: --help taken as a flag's value is not help (#153)

pflag gives a flag that takes a value the next word whatever it is, so
`gh secret set X --body --help` sets the body to "--help" and runs.
Which flags take a value depends on the command, so a help flag right
after any -x or --x word without "=" no longer exempts the command. Real
help requests seldom end with a flag: none of 65 gh, kubectl, helm,
supabase and wrangler help calls in local agent transcripts did.
supabase (effect/cli) and wrangler (yargs) never take a word starting
with "-" as a value, so they keep their rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Wrangler: --help false, -h false and --no-help turn help off (#153)

yargs-parser 21.1.1 (yargs 17.7.2) takes a "true" or "false" right
after a boolean flag as its value, reads --no-help and --no-h as off,
and keeps the last one, so `wrangler deploy --help false` deploys.
cloudpin now reads help the same way. Other spellings (--help=true,
-xh) count as off, which only adds a check. Compared with yargs-parser
on 200,000 random argument lists: cloudpin never exempted a command
yargs would run; the old rule did 8,363 times.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Wrangler: put cachedAccount's comment back above it (#153)

The previous commit inserted yargsHelp between the comment and the
function it documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* CHANGELOG and ROADMAP lines for #153 and #147

#147's lines were missed when #150 merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis deleted the fix/147-vercel-deploy-dir branch November 5, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vercel: deploy <dir> reads the link from that folder

1 participant