fix(cli): creds-recovery verb, webhook URL print, env-token 401 advice, full token in list#33
Merged
Conversation
…e, full token in list Four agent-DX follow-ups found in a live cohort dogfood (round 2, building on #32): F1 (P0): add `instant resource creds <token>` (alias `credentials`) — GETs /api/v1/resources/:id/credentials and prints the connection_url (webhook receive_url fallback; --json for the full response). Closes the broken first-provision recovery loop: `db new` frequently hits the 60s client timeout and the URL — printed only by `new` — was otherwise lost forever. Path fragment is the named const resourceCredsSuffix. F2 (P1): `webhook new` printed a blank `url` line — the human path read creds.ConnectionURL only, but /webhook/new returns receive_url. Fall back to ReceiveURL like the local token-store code already does. (--json already emits receive_url via emitProvisionJSON; verified.) F3 (P1): a 401 with INSTANT_TOKEN set advised `instant login`, which is useless — the env var SHADOWS any saved login. errSessionExpired() + classifyError() now branch on token SOURCE (new authFromEnvToken helper): an env-sourced reject tells the user to fix/unset INSTANT_TOKEN. This also fixes the dead session_expired JSON code (a 401 was mis-coded auth_required because errSessionExpired carries ExitAuthRequired). F4 (P2): `instant resources` truncated the token (`d3cef90f-a75…`) — the exact value every other command needs as an argument, so it was un-copyable. Print the FULL token; truncate the NAME column instead (new truncateName + nameDisplayMaxLen). --json unchanged. Tests: cmd/agent_dx_followups_test.go covers all four (creds happy/alias/json/ webhook-fallback/unauth/missing-token/empty/parse/server-error + token fallback; webhook receive_url human+json; env-vs-saved 401 advice + json action + flag-over-env; full-token + name-truncation + truncateName unit). 100%-patch on the diff; make ci green (build+vet+race+lint). 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 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.
Four agent-DX follow-ups found in a live cohort dogfood (round 2). All build on the just-merged #32 (whoami/--json/--no-browser) — reuse its
defaultAPIBaseURL,--jsonprovision output, and env-vs-stored auth distinction; #32's work is untouched.F1 (P0) — no way to recover a resource's connection string
instant db newfrequently times out at the 60s client timeout (server provisioning >60s under contention); the connection URL is printed ONLY bynew, so on timeout it's lost forever.GET /api/v1/resources/:id/credentialsexists but the CLI never called it.rg -n "/credentials|GetCredentials|fetchCredentials"— credentials surface lives inup.go::fetchCredentials(aup-internal helper) only; no user-facing verb.instant resource creds <token>(aliascredentials) dispatched fromresourceCmd(cmd/extras.go:103), handlerrunResourceCredentials(cmd/operate.go:612) GETs/api/v1/resources/:token/credentialsand printsconnection_url(webhookreceive_urlfallback);--jsonemits the full structured response. Path fragment is the named constresourceCredsSuffix = "/credentials"(cmd/operate.go:70).GET {API}/api/v1/resources/<token>/credentials→--json→{ok,id,token,resource_type,env,connection_url,receive_url}.TestF1_ResourceCreds_*(refetch / alias / json / webhook-receive-url-fallback / unauthenticated-exit3 / missing-token / empty-token / parse-error / server-error / token-fallback).instant resource creds --helprenders the verb). Auth/contract proven against the hermetic mock that mirrors the live GetCredentials shape.F2 (P1) — webhook
newprints a blank URLinstant webhook newsucceeds but printsurl(blank)./webhook/newreturnsreceive_url, notconnection_url; the human print path usedcreds.ConnectionURLonly.cmd/monitor.go:219— fall back tocreds.ReceiveURLwhenConnectionURLis empty (the local token-store code right above already did this).--jsonalready emitsreceive_urlviaemitProvisionJSON— verified inTestF2_WebhookNew_JSONHasReceiveURL.TestF2_WebhookNew_PrintsReceiveURL(asserts the receiver URL prints AND no blankurlline),TestF2_WebhookNew_JSONHasReceiveURL.F3 (P1) — 401 with INSTANT_TOKEN set gives wrong advice
INSTANT_TOKENyieldssession expired — run instant login(exit 3), but the env var SHADOWS any saved login, soinstant loginchanges nothing.authFromEnvToken()(cmd/up.go:386, precedence --token > INSTANT_TOKEN > saved).errSessionExpired()(cmd/errors.go) andclassifyError/sessionExpiredAction(cmd/json_error.go) branch the advice on source: env-sourced reject → "fix or unset INSTANT_TOKEN". Also fixes a latent bug — a 401 was mis-codedauth_requiredin the JSON envelope (errSessionExpired carries ExitAuthRequired) and never reached thesession_expiredclassifier; it now codessession_expiredcorrectly.TestF3_SessionExpired_EnvTokenAdvice,TestF3_SessionExpired_SavedLoginAdvice,TestF3_SessionExpired_EnvTokenJSONAction,TestF3_AuthFromEnvToken_FlagOverridesEnv; updatedTestClassifyError_AllBranchesto the corrected contract.F4 (P2) —
instant resourcestable truncates the tokend3cef90f-a75…— the exact value every other command needs as an argument, so it was un-copyable.cmd/discover.go— print the FULL token; truncate the human-facing NAME instead viatruncateName+ named constnameDisplayMaxLen(rune-safe).--jsonunchanged.TestF4_ResourcesTable_FullToken,TestF4_ResourcesTable_TruncatesLongName,TestF4_TruncateName_Unit.Gate:
make cigreen (build + vet + race + golangci-lint 0 issues). 100%-patch coverage on the diff (every changed source line exercised; verified the uncovered blocks in changed files are all pre-existing and outside the diff). typos check is warn-only; no new typos introduced.🤖 Generated with Claude Code