You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI crashes with "ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint" after switching from nightly back to stable #1611
sentry issue view <SHORT-ID> for an issue in a project the local DSN does not match, so the CLI has to list organizations.
Expected Result
sentry cli upgrade stable is the documented way back from nightly, so stable should cope with a DB from a newer schema: rebuild the cache tables, or refuse with a message saying what to do. sentry cli fix should catch the mismatch.
Actual Result
$ sentry issue view WEB-14 --json --fields shortId --log-level trace
[http] GET /api/0/organizations/ -> 200 (814ms)
Unexpected error: Error: ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
After the nightly, org_regions has PRIMARY KEY (credential_identity, source_origin, org_slug) (packages/cli/src/lib/db/schema.ts, added for multi-account auth in #1526/#1528). 0.47.0 is schema 16 and upserts org_regions with ON CONFLICT(org_slug), which SQLite rejects. Short IDs resolved through the DSN shortcut never touch that table and keep working, so the failure looks random.
initSchema only migrates when currentVersion < CURRENT_SCHEMA_VERSION, so nothing notices a newer DB, including on main. sentry cli fix prints Schema version: 16 ... No issues found (the binary's version) while select version from schema_version returns 19. It could compare each table's primary key with the declared schema; hasCompositePrimaryKey already exists for pagination_cursors.
Workaround: drop and recreate org_regions (a cache table), or delete cli.db and log in again.
(Use $SENTRY_CONFIG_DIR/cli.db if you set that.) Without sqlite3, rm ~/.config/sentry/cli.db and log in again also works.
One more thing the downgrade breaks: schema 18 moved the stored login from auth into accounts, which 0.47.0 can't read, so stable starts out logged out. If sentry auth status says so, run sentry auth login. A SENTRY_AUTH_TOKEN keeps working either way.
sentry cli upgrade stable (run from a nightly that has the fix) prepares the database for the older version before installing it. It clears the caches, copies the active login to where older versions read it, and lowers the schema version so the newer CLI re-migrates when you upgrade again.
A CLI that finds a database written by a newer version rebuilds its caches instead of crashing. With SENTRY_CLI_NO_AUTO_REPAIR=1, sentry cli fix reports the version mismatch instead of "No issues found".
Schema repair now checks every table's primary key, not only composite ones.
0.47.0 itself can't be patched. To go nightly → stable before #1612 ships in a nightly, use the workaround above.
Correction to my comment above: #1612 changed during review. sentry cli upgrade stable no longer copies your login over to the older CLI.
Once the older CLI is downloaded, the upgrade clears the caches and the stored login and lowers the schema version. After downgrading you'll need to run sentry auth login again on stable. When you upgrade again, the newer CLI re-migrates and keeps any login you made on stable. A SENTRY_AUTH_TOKEN keeps working either way.
Keeping the login across a downgrade (back up cli.db on upgrade and restore it with an undo command) is tracked in #1623. The workaround above still applies to 0.47.0 today.
Activity
linear-code commentedon Oct 23, 2026
MCP-1115
sentry-junior commentedon Oct 23, 2026
Thanks for the detailed report — the diagnosis is spot on. Fix is up in #1612.
To unblock 0.47.0 right now, drop the cache table; 0.47.0 recreates it in its own shape on the next run:
(Use
$SENTRY_CONFIG_DIR/cli.dbif you set that.) Withoutsqlite3,rm ~/.config/sentry/cli.dband log in again also works.One more thing the downgrade breaks: schema 18 moved the stored login from
authintoaccounts, which 0.47.0 can't read, so stable starts out logged out. Ifsentry auth statussays so, runsentry auth login. ASENTRY_AUTH_TOKENkeeps working either way.What #1612 changes
sentry cli upgrade stable(run from a nightly that has the fix) prepares the database for the older version before installing it. It clears the caches, copies the active login to where older versions read it, and lowers the schema version so the newer CLI re-migrates when you upgrade again.SENTRY_CLI_NO_AUTO_REPAIR=1,sentry cli fixreports the version mismatch instead of "No issues found".0.47.0 itself can't be patched. To go nightly → stable before #1612 ships in a nightly, use the workaround above.
sentry-junior commentedon Oct 23, 2026
Correction to my comment above: #1612 changed during review.
sentry cli upgrade stableno longer copies your login over to the older CLI.Once the older CLI is downloaded, the upgrade clears the caches and the stored login and lowers the schema version. After downgrading you'll need to run
sentry auth loginagain on stable. When you upgrade again, the newer CLI re-migrates and keeps any login you made on stable. ASENTRY_AUTH_TOKENkeeps working either way.Keeping the login across a downgrade (back up
cli.dbon upgrade and restore it with an undo command) is tracked in #1623. The workaround above still applies to 0.47.0 today.fix(cli): Keep the local database usable across CLI downgrades
fix(cli): Keep the database as is when a hand-off setup fails
fix(cli): Reinstate the database after a failed undo that needed a ha…
feat(cli): Back up the database on upgrade and add `cli upgrade undo` (…