Add source project key to migration reports#483
Conversation
Only the source project name was shown in the Projects section's Name column, making it hard to identify projects that share a name across servers/orgs. Adds the source key on its own line, styled like the target key already is in the Details column, in both the actual and predictive PDF/Markdown reports. Fixes #448 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| func attachFailedSourceKeys(items []EntityItem, store *common.DataStore, def sectionDef) { | ||
| if def.SourceKeyField == "" || len(items) == 0 { | ||
| return | ||
| } | ||
| mapped, err := store.ReadAll(def.InputTask) | ||
| if err != nil { | ||
| return | ||
| } | ||
| keyByName := make(map[string]string, len(mapped)) | ||
| for _, item := range mapped { | ||
| name := jsonStr(item, def.NameField) | ||
| if name == "" { | ||
| continue | ||
| } | ||
| keyByName[name] = jsonStr(item, def.SourceKeyField) |
There was a problem hiding this comment.
💡 Edge Case: Failed source-key lookup collides on duplicate project names
attachFailedSourceKeys builds keyByName keyed solely on the project name (def.NameField) and then assigns items[i].SourceKey by name match. Unlike the Succeeded/Skipped paths (which read the source key directly from the same record), Failed rows are matched purely by name. Project names are not guaranteed unique — the same name can exist across different organizations, or even be reused — so the map silently overwrites earlier entries (last-write-wins). When two projects share a name but have different source keys, a failed row can be annotated with the wrong source key, which is misleading in a migration audit report. Consider disambiguating the lookup by including the organization (the analysis ReportRow carries Organization, and generateProjectMappings rows carry sonarcloud_org_key/sonarqube_org_key), or otherwise handling the collision case rather than blindly overwriting.
Key the lookup by organization + name so projects that share a name across organizations are not conflated.:
keyByName := make(map[string]string, len(mapped))
for _, item := range mapped {
name := jsonStr(item, def.NameField)
if name == "" {
continue
}
org := jsonStr(item, "sonarcloud_org_key")
keyByName[org+"\x00"+name] = jsonStr(item, def.SourceKeyField)
}
for i := range items {
if key, ok := keyByName[items[i].Organization+"\x00"+items[i].Name]; ok {
items[i].SourceKey = key
}
}
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsMigration reports now display source project keys beneath project names for improved traceability across all outcome buckets. Note that the lookup mechanism for failed migrations relies on project names and may encounter collisions if duplicate names exist. 💡 Edge Case: Failed source-key lookup collides on duplicate project names📄 go/internal/report/summary/collect.go:822-836
Key the lookup by organization + name so projects that share a name across organizations are not conflated.🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|



Summary
migration_summary) and predictive (predictive_migration_summary) reports, since both share the same rendering pipeline.generateProjectMappings, since the analysis-report ledger backing Failed rows has no key field), and Partial/NearPerfect (carried over from the matching Succeeded/config-failure entry).Test plan
go build ./...,go vet ./...,go test ./...all passEntityItem.SourceKeypropagation across Succeeded/Skipped/Failed/Partial buckets,drawNameCellPDF rendering (bold/regular font split, border pattern parity withdrawWrappedCell), and Markdown Name-cell rendering (Name<br>**KEY**)Fixes #448
🤖 Generated with Claude Code