gastownhall/beads · error
get issues by IDs: scan label: %w
Error message
get issues by IDs: scan label: %w
What it means
Wraps a labelRows.Scan failure while decoding (issue_id, label) pairs during label hydration in GetIssuesByIDsInTx. The label query succeeded but a returned row has unexpected column types or values.
Source
Thrown at internal/storage/issueops/dependencies.go:1077
}
_ = rows.Close()
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("get issues by IDs: rows: %w", err)
}
// Hydrate labels.
if len(issueMap) > 0 {
labelRows, err := tx.QueryContext(ctx, fmt.Sprintf(
`SELECT issue_id, label FROM %s WHERE issue_id IN (%s) ORDER BY issue_id, label`,
pair.labelTbl, inClause), args...)
if err != nil {
return nil, fmt.Errorf("get issues by IDs: labels from %s: %w", pair.labelTbl, err)
}
for labelRows.Next() {
var issueID, label string
if scanErr := labelRows.Scan(&issueID, &label); scanErr != nil {
_ = labelRows.Close()
return nil, fmt.Errorf("get issues by IDs: scan label: %w", scanErr)
}
if issue, ok := issueMap[issueID]; ok {
issue.Labels = append(issue.Labels, label)
}
}
_ = labelRows.Close()
if err := labelRows.Err(); err != nil {
return nil, fmt.Errorf("get issues by IDs: label rows: %w", err)
}
}
}
}
return allIssues, nil
}
// GetDependenciesWithMetadataInTx returns issues that the given issueID depends on,
// along with the dependency type. Works within an existing transaction.View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the offending label row for NULL/malformed values and fix the data
- Run outstanding migrations to restore schema/scan alignment
- Restore corrupted rows from backup if data corruption is confirmed
Defensive patterns
Strategy: validation
Validate before calling
// Data preflight: detect label rows that would fail scanning (NULL label): rows, err := db.QueryContext(ctx, `SELECT issue_id FROM labels WHERE label IS NULL`) // If any rows return, clean or restore them before calling batch fetches.
Try / catch
_, err := GetIssuesByIDsInTx(ctx, tx, ids, nil)
if err != nil && strings.Contains(err.Error(), "scan label") {
// Deterministic data/schema problem — do not retry blindly.
return fmt.Errorf("corrupt label row; run integrity repair: %w", err)
} Prevention
- Never hand-edit label rows; use the library's label APIs
- Add NULL-constraint checks on label columns in migrations
- Run integrity checks after crashes or manual DB surgery
- Restore suspect label rows from backup rather than patching in place
When it happens
Trigger: labelRows.Scan(&issueID, &label) fails on a row — e.g. label column is NULL or has a non-string type that doesn't match the declared schema.
Common situations: Corrupt or hand-edited label rows containing NULLs; schema drift between the label table and the scan code after a partial migration.
Related errors
- db: ChildCounterSQLRepository.NextChildID: scan: %w
- db: CommentSQLRepository.CountsByIssueIDs: scan: %w
- db: CommentSQLRepository.ListByIssueIDs: scan: %w
- db: LabelSQLRepository.List: scan: %w
- db: LabelSQLRepository.ListByIssueIDs: scan: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/3e0e76853c2463c1.
Report an issue: GitHub.