JiraIssueChangelogItems primary key collision when Jira reports multiple items with the same field in one changelog entry
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 64/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
从 backend/plugins/jira/models/issue_changelog.go 开始,然后跟踪 Jira extractor 针对 JiraIssueChangelogItems 的 upsert 路径。复现两个具有相同字段的 item,并检查 schema 变更的影响;完成标准是重新提取后两个 item 都能无冲突地持久化,并为报告的案例提供 regression coverage。
由索引模型根据 Issue 内容生成。
描述
Summary
JiraIssueChangelogItems has a composite primary key of (ConnectionId, ChangelogId, Field). When Jira returns multiple items with the same Field value within a single changelog history entry, the second item silently overwrites the first on upsert.
Steps to reproduce
- Have a Jira issue where a single-value field (e.g.
fixVersions) is changed from value A to value B in one action - Jira's API represents this as two changelog items in the same history entry:
Fix Version: null → B(add)Fix Version: A → null(remove)
- Both items share the same
ChangelogIdandField = "Fix Version" - Run the Jira extractor — only one item survives in
_tool_jira_issue_changelog_items
Expected behavior
Both changelog items should be stored — the add and the remove.
Actual behavior
The second item overwrites the first because they collide on the primary key (ConnectionId, ChangelogId, Field).
Impact
Any downstream query that relies on changelog items to detect whether a specific value was ever added to a field (e.g. filtering issues by historical fixVersions) will produce incorrect results. This affects fixVersions, labels, components, affectedVersions, and any other field where Jira emits multiple items with the same field name in one history entry.
Suggested fix
Add a disambiguating column to the primary key — for example an item ordinal/index within the changelog entry. The model is in backend/plugins/jira/models/issue_changelog.go:
type JiraIssueChangelogItems struct {
ConnectionId uint64 `gorm:"primaryKey"`
ChangelogId uint64 `gorm:"primaryKey"`
Field string `gorm:"primaryKey"`
// no item-level disambiguator
}
Existing data would need re-extraction after the schema change, since collided rows already lost one of the two items.
Version
Verified on v1.0.3-beta10 and confirmed the PK is unchanged on main as of 2026-08-17.
- 主要语言
- Go
- 星标
- 3.1k
- 派生
- 812
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 51
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/devlake 的其他 Issue
-
type/bug
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 35/100
-
type/bug
难度 4/5 3-5 天 新手友好度 52/100
-
难度 5/5 一周以上 新手友好度 35/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
santhosh-tekuri/jsonschema#276 ·