Repository navigation
Reject --auth without a credential file path - #370
Open
JayOfTheKeyboard wants to merge 1 commit into
Open
JayOfTheKeyboard wants to merge 1 commit into
JayOfTheKeyboard wants to merge 1 commit into
Conversation
JayOfTheKeyboard
force-pushed
the
fix/auth-flag-missing-value
branch
from
October 11, 2026 07:15
47ba0e1 to
ca395c2
Compare
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.
Motivation
cli.tsxreads the global--auth <path>flag by hand before incur sees argv. When no path follows the flag, the value isundefined. The CLI then falls back to the default credential store, and it ignoresLINK_AUTH_FILEas well. So a command meant for a separate session runs against the default one, and it still exits 0.Reproduced on
main(a4497ca). The default store held a valid session,LINK_AUTH_FILEpointed at a second one, and the path after--authwas left off:mainauth logout --auth(value missing,LINK_AUTH_FILEset)INVALID_INPUT, exit 1, nothing touchedauth status --auth --format json--formatas the path, creates./--format.json, prints human output, exit 0INVALID_INPUT, exit 1, no file createdauth status --auth ""INVALID_INPUT, exit 1auth status --auth work.jsonwork.jsonSummary
--authparsing intotakeAuthFileFlag()(packages/cli/src/auth/auth-file-flag.ts). It still strips the flag and its value, and it still falls back toLINK_AUTH_FILEwhen the flag is absent.-is reported asMissing value for flag: --auth (expected a credential file path; write ./-name for a path that starts with "-"). The following flag is left in argv for incur to parse.cli.use()middleware callingc.error({ code: 'INVALID_INPUT', ... }), so it comes out in the requested format with exit code 1, like other input errors. The wording follows incur's ownMissing value for flag: --config.Key design considerations
-is now refused../-creds.jsonstill works.--auth=pathis not supported. That is unchanged, and it matches incur's other global flags (--format=jsonis also "Unknown flag")..jsonstill gets.jsonappended (--auth credsusescreds.json). That looks deliberate from Specify credential file #81, so this PR leaves it alone.--help,--version,--llms,skills add,mcp add,completions) don't run middleware, so they still ignore a bare--auth. None of them read credentials. Under--mcpthe server still starts, but every tool call returns the error.Tests
src/__tests__/cli.test.ts, new--auth without a pathblock, run against the built CLI. Both tests fail onmainand pass with the fix:errors instead of logging out the default sessionalso checks that no/device/revokerequest is made and that theLINK_AUTH_FILEtarget isn't created. Onmain:expected undefined to be 'prod_test_refresh_token', meaning the default session was deleted.does not take the next flag as the credential file path. Onmain:expected true to be false, meaning--format.jsonwas created.src/auth/__tests__/auth-file-flag.test.ts: unit tests for the parser (value, env fallback, missing/empty/flag-as-value, argv left for incur).-check (4), dropping the empty-string check (1 unit), splicing the following flag away (1 unit), and falling back toLINK_AUTH_FILEon a missing value (3 unit).Validation:
pnpm turbo run buildandpnpm turbo run typecheckpass, andpnpm biome checkis clean on the changed files.@stripe/link-sdkpasses 211/211 and@stripe/link-integrations-better-authpasses 44/44.@stripe/link-clihas 659 tests (651 + 8 new). On a heavily loaded machine, the full CLI run had 1 to 8 timing-dependent failures, inserve.test.tsand therequest agent attributionblock. A different few failed on each run, and unmodifiedmainfailed in the same blocks on the same machine. None are in the tests added here.