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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user