fix(ci): resolve lint and test failures

Fix two CI failures that were blocking main:

1. Lint error in cmd/bd/onboard.go:126
   - Unchecked fmt.Fprintf return value
   - Fixed by explicitly ignoring with _, _

2. Test failures in internal/storage/sqlite
   - TestCreateIssues/duplicate_ID_error was passing but
     TestCreateIssuesRollback/rollback_on_conflict_with_existing_ID failed
   - Root cause: CreateIssues used INSERT OR IGNORE which silently
     ignored duplicate IDs instead of returning an error
   - Fixed by adding duplicate ID detection in EnsureIDs():
     a) Check for duplicates within the batch
     b) Check for conflicts with existing database IDs

Both fixes are minimal and targeted to unblock CI.
This commit is contained in:
Charles P. Cross
2025-12-18 16:07:09 -05:00
parent 7f9ee3d1c4
commit cb59bb3ec8
2 changed files with 17 additions and 2 deletions

View File

@@ -223,9 +223,24 @@ func tryResurrectParent(parentID string, issues []*types.Issue) bool {
func EnsureIDs(ctx context.Context, conn *sql.Conn, prefix string, issues []*types.Issue, actor string, orphanHandling OrphanHandling, skipPrefixValidation bool) error {
usedIDs := make(map[string]bool)
// First pass: record explicitly provided IDs
// First pass: record explicitly provided IDs and check for duplicates within batch
for i := range issues {
if issues[i].ID != "" {
// Check for duplicate IDs within the batch
if usedIDs[issues[i].ID] {
return fmt.Errorf("duplicate issue ID within batch: %s", issues[i].ID)
}
// Check if ID already exists in database
var existingCount int
err := conn.QueryRowContext(ctx, `SELECT COUNT(*) FROM issues WHERE id = ?`, issues[i].ID).Scan(&existingCount)
if err != nil {
return fmt.Errorf("failed to check ID existence: %w", err)
}
if existingCount > 0 {
return fmt.Errorf("issue ID already exists: %s", issues[i].ID)
}
// Validate that explicitly provided ID matches the configured prefix (bd-177)
// Skip validation during import to allow issues with different prefixes (e.g., from renamed repos)
if !skipPrefixValidation {