Uh oh!
There was an error while loading. Please reload this page.
fix(auth): surface real auth errors, stop test suite wiping dev credentials - #9
Merged
Merged
Conversation
… Object]
The auth middleware returns { status, error: { message } } while every other
endpoint returns { error: string }. The client assumed the flat shape, so any
401 (invalid, expired, or revoked credential) rendered as '[object Object]'
in the CLI, SDK, and MCP tools, hiding the server's actual explanation.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>…s exist resolveAuth threw a plain Error, and the command factory only formats AutoDevError — so a brand-new user's first command crashed with a raw Node stack trace. resolveAuth now throws AutoDevError(401) with the login hint as the suggestion, and the factory formats unexpected errors as a fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tials The clearCredentials test called the real implementation against the module-level default storage: it POSTed a live token revocation to id.org.ai with the developer's stored access token, then deleted ~/.id.org.ai/token and ~/.oauth.do/token. Running 'pnpm test' logged the developer out of auto.dev. test/setup.ts now points HOME/USERPROFILE at a fresh temp dir for every run, and the clearCredentials test also mocks fetch so no revoke can escape. Co-Authored-By: Claude Fable 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 freeto 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.
What broke
A user reported the SDK "wasn't working correctly with auth." Root-causing found three distinct bugs:
1. Every auth failure rendered as
✖ 401: [object Object]The auth middleware returns
{ status, error: { message } }while every other endpoint returns{ error: string }.src/core/client.tsassumed the flat shape, so the object became the error message. Any invalid/expired/revoked credential produced[object Object]across CLI, programmatic SDK (err.message), and MCP tools — hiding the server's actual explanation ("Authentication required. Get your API key at …").After:
✖ 401: Authentication required. Get your API key at https://auto.dev/dashboard/api-keys(verified against the live API).2. First run with no credentials crashed with a raw stack trace
resolveAuththrew a plainError; the command factory only formatsAutoDevErrorand rethrew everything else. A brand-new user's first command dumped a Node stack trace instead of the login hint.After:
✖ 401: No API key found+Set AUTODEV_API_KEY or run: auto login. The factory also formats any unexpected error as a fallback (e.g. offlinefetch failed).3.
pnpm testlogged the developer out of auto.dev (!)The
clearCredentialstest (test/auth/auth-origin-headers.test.ts) ran the real implementation against the module-level default storage: it POSTed a live token revocation to id.org.ai with the developer's stored access token, then deleted~/.id.org.ai/tokenand~/.oauth.do/token. Harmless in CI (no credentials there — the test even says so), destructive on any dev machine. Confirmed by planting a dummy token in a sandbox HOME and watching the suite delete it.After:
test/setup.tssandboxesHOME/USERPROFILEinto a fresh temp dir for every vitest run, and the test also mocksfetchso no revoke can escape. Forensic re-check: planted token survives the full suite.Verification
tsc --noEmitclean,tsupbuild cleanKnown gaps left open (not this PR)
new AutoDev({})never reads the storedauto logintoken — doc or SDK should change (follow-up issue)tcoreturns 404 for VINs that resolve on every other endpoint — API-side, not auth🤖 Generated with Claude Code