Skip to content

app dev-tunnel: a 401 "Apps are not enabled" is shown as "not logged in" #1004

Backlog

Description

@JustMaier

What happens

devTunnelError (internal/appapi/appblocks.go) maps every 401 from blocks.startDevTunnel, stopDevTunnel and friends to unauthorizedError(""), dropping the server's message. The comment there assumes a 401 on this path is always the origin gate ("Please use the public API instead").

It isn't. The site's blocks router also refuses a mutation with HTTP 401 and the message Apps are not enabled when the App Blocks flag is off for the caller. An author whose login is valid then sees:

Error: not logged in (401) — run `civitai login` (or set CIVITAI_TOKEN). ...

and is sent to log in again, which cannot help. civitai/civitai#11480 fixed one cause of that refusal (a moderator on a civitai login token). The message is still wrong for anyone the flag refuses.

Also

internal/cmd/app_dev_tunnel.go (~:677, the 403 insufficient-scope arm) says "an OAuth civitai login token can't open dev tunnels". internal/appapi/oauth.go (DeviceScope, :46-52) says the login token requests and carries the AppBlocksDevTunnel bit, so the hint is stale.

Fix

  • On a 401, keep the server message unless it is the origin-gate string. For example: Apps are not enabled → "Apps aren't enabled for this account (401): Apps are not enabled", without the log-in remedy.
  • Update the stale hint at app_dev_tunnel.go ~:677.

Closing condition

This closes when a civitai/cli PR merges whose devTunnelError test feeds a 401 body {"error":{"json":{"message":"Apps are not enabled","data":{"httpStatus":401}}}} and asserts that the returned error contains Apps are not enabled and does not tell the user to log in again, and whose diff updates the stale hint. The reviewer of that PR checks both.

Found while debugging civitai/civitai#11480.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions