Skip to content

[Bug]: Desktop fails to start when state DB migration ids collide with a different build (auth_sessions missing scopes) #21106

Closed as not planned

Description

@Cyb3rN8

Summary

Desktop shows PrimaryEnvironmentRequestError … DesktopLocalEnvironmentAuthSessionBootstrapError: Failed to create the local desktop bearer session on every launch when the state DB's migration ids were already used by a different build. The app is bricked until the DB is hand-repaired, and the UI error hides the real cause. Same user-visible stack as #17792 (closed; the explanation there was a transient loopback failure, which did not apply here).

Root cause (from server.trace.ndjson)

POST /oauth/token fails with access_token_issuance_failed → AuthSessionRepository.createReplacingActive → table auth_sessions has no column named scopes.

statev2.sqlite was created by importing an older state.sqlite. That DB had migration ids 1–32 recorded as applied, but ids 31/32 there were ProjectionThreadContextBindings / ProjectionTurnsContextBlocks (written by a different, Nightly-labelled build; these names are not in main). In the current build 31/32 are AuthAuthorizationScopes (adds scopes, drops/recreates the auth tables) and AuthPairingProofKeyThumbprint. The migrator keys on id only, so both were treated as done and skipped. Migrations 33+ then applied normally, which is why only the auth tables were stale (auth_sessions had client_surface from 041 but no scopes).

Repro

  1. Have a state DB whose effect_sql_migrations has id 31 under a different name than 031_AuthAuthorizationScopes.
  2. Launch the current desktop build.

Workaround

Quit the app, back up ~/.t3/userdata/statev2.sqlite, then recreate auth_pairing_links and auth_sessions per migrations 031 + 032 (+ the two columns from 041). Existing auth sessions/pairings are lost by design.

Suggested fixes

  • On import/startup, compare (migration_id, name) against the bundled list and rerun or refuse on a name mismatch instead of trusting ids.
  • Surface the backend's access_token_issuance_failed reason in the desktop error instead of the generic bootstrap message.

Version

T3 Code (Beta) 0.1.0, macOS.

Activity

  1. juliusmarminge commented on Oct 18, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Closing as unsupported database reuse. Migrations 31 and 32 have been AuthAuthorizationScopes and AuthPairingProofKeyThumbprint on main since June, and the names your database recorded for those ids don't appear anywhere in this repo, so it was written by a build we don't ship. The statev2 import copies state.sqlite as-is, migration history included, and the migrator follows ids, only logging a warning when names diverge. Please keep a backup of that database before changing it. Requests to refuse mismatched names for every id, or to show the server's token error in the desktop app, belong in Ideas: https://github.com/pingdotgg/t3code/discussions/new?category=ideas

  2. added
    enhancement
    via-triage
    on Oct 18, 2026
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

    enhancementvia-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions