Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

CLI crashes with "ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint" after switching from nightly back to stable

Aperta
#1,611 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sentry-junior ci sta già lavorando.

Dal 23/10/2026.

  • #1612 di @sentry-junior — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
bun, sqlite, typescript
Ambito
cli, database

Direzione di ricerca

Start with packages/cli/src/lib/db/schema.ts and trace initSchema, the org_regions upsert, and sentry cli fix; the report also points to hasCompositePrimaryKey for pagination_cursors. Reproduce by migrating the CLI database to schema 19, then running stable 0.47.0 against an organization list. Done means the version mismatch is detected and handled with a clear recovery path, and the reported crash no longer occurs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment
  • sentry CLI stable [email protected], installed as a Bun global (install.method bun in cli.db)
  • Previously ran nightly 0.48.0-dev.1792585391, which migrated ~/.config/sentry/cli.db to schema_version 19
  • Linux 6.18, Bun 1.4.4, sentry.io SaaS, one org with two projects
Steps to Reproduce
  1. sentry cli upgrade nightly, then run any authenticated command (the DB migrates to schema 19).
  2. sentry cli upgrade stable (or reinstall [email protected]).
  3. 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.

Lingua principale
TypeScript
Stelle
938
Fork
166
Merge medio
1g 4h
PR unite (30g)
175

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/toolkit

Tutte le issue di getsentry/toolkit

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.