Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#1,611 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
bun, sqlite, typescript
领域
cli, database

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
938
派生
166
平均合并
1 天 7 小时
30 天内合并 PR
156

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/toolkit 的其他 Issue

查看 getsentry/toolkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。