fix(dev-token): warn at mint when the token can't spend (read-only/OAuth) - #48
Merged
Conversation
A dev token minted from an OAuth login (`civitai login`) carries no `ai:write:budgeted` scope — the server strips it (the civitai-cli OAuth client has no AI Services). The resulting read-only token makes `npm run dev:live` silently dead-end: clicking Generate posts REQUEST_CONSENT, and the live host can't grant a scope the token lacks, so nothing happens — no network, no error. Catch it at the source. `app dev-token` now decodes the minted JWT payload (no signature verification — server's job) and, when `ai:write:budgeted` is absent, prints a loud, actionable stderr warning steering to `civitai login --token <key>` + a re-mint. The token still goes to stdout cleanly so `--env >> .env.development.local` is unaffected. Tests: tokenCanSpend table (budgeted / read-only / empty / malformed) + the command warns on a read-only JWT and stays silent on a spendable one. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 26, 2026
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.
What
A dogfood of
dev:livehit a silent dead-end: Generate did nothing — no network, no console, no error. Root cause: the dev token was minted from an OAuth login (civitai login), so the server strippedai:write:budgeted. The resulting read-only token makes the live host's Generate postREQUEST_CONSENT, which live mode can't grant → silent hang.This catches it at the source:
app dev-tokennow decodes the minted JWT payload and, whenai:write:budgetedis absent, prints a loud, actionable stderr warning:The token still goes to stdout cleanly, so
--env >> .env.development.localis unaffected.Verification
go build ./...+go test ./internal/...green. New tests:tokenCanSpendtable (budgeted / read-only / empty / malformed JWTs) + the command warns on a read-only minted JWT and stays silent on a spendable one.Sibling fix
The runtime half is
civitai/civitai-app-starters(the live host now also warns at startup + logs on REQUEST_CONSENT instead of silently swallowing it).🤖 Generated with Claude Code