{"record":{"id":"cddd13abd7b544af","repo":"gastownhall/beads","slug":"get-issues-by-ids-from-s-w","errorCode":null,"errorMessage":"get issues by IDs from %s: %w","messagePattern":"get issues by IDs from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/dependencies.go","lineNumber":1048,"sourceCode":"\t\t\tend := start + queryBatchSize\n\t\t\tif end > len(pair.ids) {\n\t\t\t\tend = len(pair.ids)\n\t\t\t}\n\t\t\tbatch := pair.ids[start:end]\n\n\t\t\tplaceholders := make([]string, len(batch))\n\t\t\targs := make([]any, len(batch))\n\t\t\tfor i, id := range batch {\n\t\t\t\tplaceholders[i] = \"?\"\n\t\t\t\targs[i] = id\n\t\t\t}\n\t\t\tinClause := strings.Join(placeholders, \",\")\n\n\t\t\trows, err := tx.QueryContext(ctx, fmt.Sprintf(\n\t\t\t\t`SELECT %s FROM %s %s WHERE id IN (%s)`,\n\t\t\t\tIssueSelectColumns, pair.table, sqlbuild.LeaseJoin(pair.table), inClause), args...)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs from %s: %w\", pair.table, err)\n\t\t\t}\n\t\t\tissueMap := make(map[string]*types.Issue)\n\t\t\tfor rows.Next() {\n\t\t\t\tissue, scanErr := ScanIssueFrom(rows)\n\t\t\t\tif scanErr != nil {\n\t\t\t\t\t_ = rows.Close()\n\t\t\t\t\treturn nil, fmt.Errorf(\"get issues by IDs: scan: %w\", scanErr)\n\t\t\t\t}\n\t\t\t\tallIssues = append(allIssues, issue)\n\t\t\t\tissueMap[issue.ID] = issue\n\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 {","sourceCodeStart":1030,"sourceCodeEnd":1066,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/dependencies.go#L1030-L1066","documentation":"Wraps a QueryContext error while fetching issue rows by ID from one of the issue tables (permanent or wisp) during GetIssuesByIDsInTx. The table name is embedded in the message (%s) so you know which of the paired tables the SELECT failed against.","triggerScenarios":"The parameterized `SELECT ... FROM <issues|wisps> ... WHERE id IN (...)` query returns a driver error — bad SQL, missing table, connection failure, or too many placeholders for a huge ID list.","commonSituations":"Very large ID lists exceeding driver placeholder limits, missing migration (table absent), connection dropped mid-transaction, or SQL syntax drift after a driver upgrade.","solutions":["Batch the ID list into chunks if it is very large (placeholder limit)","Check the wrapped driver error and the named table exists (run migrations)","Retry on transient connection/lock errors","Verify IssueSelectColumns/LeaseJoin SQL fragments are compatible with your driver version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate inputs and DB readiness before the batch fetch:\nif len(ids) == 0 { return nil }\nif len(ids) > maxPlaceholders { ids = chunk(ids, maxPlaceholders) } // avoid placeholder overflow\nif err := txErr(tx); err != nil { return err }\n// Confirm the issue tables exist:\nrows, err := db.QueryContext(ctx, `SELECT name FROM sqlite_master WHERE type='table' AND name IN ('issues','wisps')`)","typeGuard":"func validIDList(ids []string) bool {\n    for _, id := range ids {\n        if id == \"\" || len(id) > maxIDLen { return false }\n    }\n    return len(ids) > 0 && len(ids) <= maxPlaceholders\n}","tryCatchPattern":"issues, err := GetIssuesByIDsInTx(ctx, tx, ids, nil)\nvar qErr *IssueFetchError\nif err != nil {\n    if strings.Contains(err.Error(), \"get issues by IDs from\") && isTransientDBError(err) {\n        issues, err = GetIssuesByIDsInTx(ctx, tx, ids, nil) // retry transient\n    }\n    if err != nil { return err }\n}","preventionTips":["Chunk very large ID lists to stay under driver placeholder limits","Run migrations before upgrading the binary (tables must match code)","Use context timeouts longer than expected query duration","Validate IDs are non-empty before calling batch fetches"],"tags":["database","sql","go"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}