From 0abd21f7a69aa46bfddfa2bc9a4b2b49ff95b700 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Wed, 5 Nov 2025 00:54:25 -0800 Subject: [PATCH] Fix bd-gdzd: Treat same-content-different-ID as update When import finds same content hash with different IDs, treat it as an update to the existing issue instead of failing with 'rename collision' error. This handles edge cases like test data, legacy data, or data corruption gracefully. Amp-Thread-ID: https://ampcode.com/threads/T-e58a11be-cbbb-4a75-86d5-fc51af8f51d2 Co-authored-by: Amp --- internal/importer/importer.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/importer/importer.go b/internal/importer/importer.go index b706c717..ed70faa7 100644 --- a/internal/importer/importer.go +++ b/internal/importer/importer.go @@ -289,9 +289,29 @@ func handleRename(ctx context.Context, s *sqlite.SQLiteStorage, existing *types. // The rename is already complete in the database return deletedID, nil } - // REMOVED (bd-8e05): Sequential ID collision handling during rename - // With hash-based IDs, rename collisions should not occur - return "", fmt.Errorf("rename collision handling removed - should not occur with hash IDs") + // With hash IDs, same content should produce same ID. If we find same content + // with different IDs, treat it as an update to the existing ID (not a rename). + // This handles edge cases like test data, legacy data, or data corruption. + // Keep the existing ID and update fields if incoming has newer timestamp. + if incoming.UpdatedAt.After(existing.UpdatedAt) { + // Update existing issue with incoming's fields + updates := map[string]interface{}{ + "title": incoming.Title, + "description": incoming.Description, + "design": incoming.Design, + "acceptance_criteria": incoming.AcceptanceCriteria, + "notes": incoming.Notes, + "external_ref": incoming.ExternalRef, + "status": incoming.Status, + "priority": incoming.Priority, + "issue_type": incoming.IssueType, + "assignee": incoming.Assignee, + } + if err := s.UpdateIssue(ctx, existing.ID, updates, "importer"); err != nil { + return "", fmt.Errorf("failed to update issue %s: %w", existing.ID, err) + } + } + return "", nil /* OLD CODE REMOVED (bd-8e05) // Different content - this is a collision during rename