Skip to content

fix(dev-token): warn at mint when the token can't spend (read-only/OAuth) - #48

Merged
ZacxDev merged 1 commit into
mainfrom
zach/dev-token-readonly-warn
Jun 26, 2026
Merged

fix(dev-token): warn at mint when the token can't spend (read-only/OAuth)#48
ZacxDev merged 1 commit into
mainfrom
zach/dev-token-readonly-warn

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

A dogfood of dev:live hit 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 stripped ai:write:budgeted. The resulting read-only token makes the live host's Generate post REQUEST_CONSENT, which live mode can't grant → silent hang.

This catches it at the source: app dev-token now decodes the minted JWT payload and, when ai:write:budgeted is absent, prints a loud, actionable stderr warning:

⚠  This token is READ-ONLY — it has no `ai:write:budgeted` scope, so `npm run dev:live`
   will NOT spend Buzz or generate (Generate dead-ends silently).
   You're authenticated with an OAuth login. Real generation needs a full-scope personal API key:
     civitai login --token <key>      # create one at https://civitai.com/user/account
     civitai app dev-token <slug> --env >> .env.development.local   # re-mint, then restart dev:live

The token still goes to stdout cleanly, so --env >> .env.development.local is unaffected.

Verification

go build ./... + go test ./internal/... green. New tests: tokenCanSpend table (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

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>
@ZacxDev
ZacxDev merged commit 00334ad into main Jun 26, 2026
5 checks passed
@ZacxDev
ZacxDev deleted the zach/dev-token-readonly-warn branch June 26, 2026 17:16
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.

1 participant