{"record":{"id":"3e0e76853c2463c1","repo":"gastownhall/beads","slug":"get-issues-by-ids-scan-label-w","errorCode":null,"errorMessage":"get issues by IDs: scan label: %w","messagePattern":"get issues by IDs: scan label: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/dependencies.go","lineNumber":1077,"sourceCode":"\t\t\t}\n\t\t\t_ = rows.Close()\n\t\t\tif err := rows.Err(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs: rows: %w\", err)\n\t\t\t}\n\n\t\t\t// Hydrate labels.\n\t\t\tif len(issueMap) > 0 {\n\t\t\t\tlabelRows, err := tx.QueryContext(ctx, fmt.Sprintf(\n\t\t\t\t\t`SELECT issue_id, label FROM %s WHERE issue_id IN (%s) ORDER BY issue_id, label`,\n\t\t\t\t\tpair.labelTbl, inClause), args...)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs: labels from %s: %w\", pair.labelTbl, err)\n\t\t\t\t}\n\t\t\t\tfor labelRows.Next() {\n\t\t\t\t\tvar issueID, label string\n\t\t\t\t\tif scanErr := labelRows.Scan(&issueID, &label); scanErr != nil {\n\t\t\t\t\t\t_ = labelRows.Close()\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs: scan label: %w\", scanErr)\n\t\t\t\t\t}\n\t\t\t\t\tif issue, ok := issueMap[issueID]; ok {\n\t\t\t\t\t\tissue.Labels = append(issue.Labels, label)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t_ = labelRows.Close()\n\t\t\t\tif err := labelRows.Err(); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs: label rows: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn allIssues, nil\n}\n\n// GetDependenciesWithMetadataInTx returns issues that the given issueID depends on,\n// along with the dependency type. Works within an existing transaction.","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/dependencies.go#L1059-L1095","documentation":"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.","triggerScenarios":"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.","commonSituations":"Corrupt or hand-edited label rows containing NULLs; schema drift between the label table and the scan code after a partial migration.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Data preflight: detect label rows that would fail scanning (NULL label):\nrows, err := db.QueryContext(ctx, `SELECT issue_id FROM labels WHERE label IS NULL`)\n// If any rows return, clean or restore them before calling batch fetches.","typeGuard":null,"tryCatchPattern":"_, err := GetIssuesByIDsInTx(ctx, tx, ids, nil)\nif err != nil && strings.Contains(err.Error(), \"scan label\") {\n    // Deterministic data/schema problem — do not retry blindly.\n    return fmt.Errorf(\"corrupt label row; run integrity repair: %w\", err)\n}","preventionTips":["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"],"tags":["database","sql","scan","go"],"backgroundTag":"row-scan-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}