{"record":{"id":"932b6789d85da816","repo":"gastownhall/beads","slug":"db-labelsqlrepository-listbyissueids-w","errorCode":null,"errorMessage":"db: LabelSQLRepository.ListByIssueIDs: %w","messagePattern":"db: LabelSQLRepository\\.ListByIssueIDs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/label.go","lineNumber":172,"sourceCode":"\tresult := make(map[string][]string)\n\tif len(issueIDs) == 0 {\n\t\treturn result, nil\n\t}\n\tplaceholders := make([]string, len(issueIDs))\n\targs := make([]any, len(issueIDs))\n\tfor i, id := range issueIDs {\n\t\tplaceholders[i] = \"?\"\n\t\targs[i] = id\n\t}\n\ttable := pickLabelTable(opts.UseWispsTable)\n\t//nolint:gosec // G201: table is one of two hardcoded constants\n\tq := fmt.Sprintf(\n\t\t\"SELECT issue_id, label FROM %s WHERE issue_id IN (%s) ORDER BY issue_id, label\",\n\t\ttable, strings.Join(placeholders, \",\"),\n\t)\n\trows, err := r.runner.QueryContext(ctx, q, args...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"db: LabelSQLRepository.ListByIssueIDs: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar issueID, label string\n\t\tif err := rows.Scan(&issueID, &label); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"db: LabelSQLRepository.ListByIssueIDs: scan: %w\", err)\n\t\t}\n\t\tresult[issueID] = append(result[issueID], label)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"db: LabelSQLRepository.ListByIssueIDs: rows: %w\", err)\n\t}\n\treturn result, nil\n}\n\nfunc (r *labelSQLRepositoryImpl) DeleteAllForIDs(ctx context.Context, ids []string, opts domain.LabelOpts) (int, error) {\n\tif len(ids) == 0 {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/label.go#L154-L190","documentation":"LabelSQLRepository.ListByIssueIDs failed to execute its SELECT of (issue_id, label) for the given issue IDs. The database rejected or failed to run the query, so no rows were returned at all.","triggerScenarios":"Calling ListByIssueIDs with a malformed IN-clause (built from issueIDs), or when the labels table does not exist (e.g. wisps table mode enabled but table absent), or the connection/query fails.","commonSituations":"Empty or huge issueIDs list producing too many placeholders beyond driver limits; labels table not yet created because schema migrations did not run; querying wisps table that was never materialized; database locked or unreachable.","solutions":["Unwrap the error to see the driver cause (no such table, syntax, too many parameters)","Verify the labels table exists: run schema setup/migrations before repository calls","Reduce the size of issueIDs (batch the call) if hitting placeholder/parameter limits","If using wisps table mode, confirm the wisps labels table exists or handle IsTableNotExist upstream"],"exampleFix":"// before\nresult, err := repo.ListByIssueIDs(ctx, thousandsOfIDs, opts)\n// after\nfor i := 0; i < len(ids); i += 500 {\n    batch := ids[i:min(i+500, len(ids))]\n    r, err := repo.ListByIssueIDs(ctx, batch, opts)\n    ...\n}","handlingStrategy":"validation","validationCode":"// validate inputs and schema before the call\nif len(issueIDs) == 0 { return map[string][]string{}, nil }\nif len(issueIDs) > 500 { /* batch */ }\n// confirm table exists\nvar one int\nerr := db.QueryRow(`SELECT 1 FROM sqlite_master/dolt_tables WHERE name='issue_labels'`).Scan(&one)","typeGuard":null,"tryCatchPattern":"m, err := repo.ListByIssueIDs(ctx, ids, opts)\nif err != nil {\n    if dberrors.IsTableNotExist(errors.Unwrap(err)) {\n        return map[string][]string{}, nil\n    }\n    return err\n}","preventionTips":["Batch large ID slices under driver parameter limits","Run migrations before any repository call","Handle IsTableNotExist for optional wisps tables","Keep ID strings within column size limits"],"tags":["go","database","sql","query"],"backgroundTag":"sql-query-execution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}