{"record":{"id":"3eda34cc3ea109ff","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-listbyissueids-in","errorCode":null,"errorMessage":"db: DependencySQLRepository.ListByIssueIDs (in): %w","messagePattern":"db: DependencySQLRepository\\.ListByIssueIDs \\(in\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":442,"sourceCode":"\t\tq := fmt.Sprintf(\n\t\t\t`SELECT %s FROM %s WHERE issue_id IN (%s)%s ORDER BY issue_id`,\n\t\t\tdepSelectColumns, table, idPlaceholders, typeWhere,\n\t\t)\n\t\targs := combineArgs(idArgs, typeArgs)\n\t\tif err := r.queryDeps(ctx, q, args, result.Outgoing, true); err != nil {\n\t\t\treturn domain.DepBulkResult{}, fmt.Errorf(\"db: DependencySQLRepository.ListByIssueIDs (out): %w\", err)\n\t\t}\n\t}\n\n\tif opts.Direction == domain.DepDirectionBoth || opts.Direction == domain.DepDirectionIn {\n\t\t//nolint:gosec // G201: table, depSelectColumns, depTargetExpr are hardcoded\n\t\tq := fmt.Sprintf(\n\t\t\t`SELECT %s FROM %s WHERE %s IN (%s)%s ORDER BY issue_id`,\n\t\t\tdepSelectColumns, table, depTargetExpr, idPlaceholders, typeWhere,\n\t\t)\n\t\targs := combineArgs(idArgs, typeArgs)\n\t\tif err := r.queryDeps(ctx, q, args, result.Incoming, false); err != nil {\n\t\t\treturn domain.DepBulkResult{}, fmt.Errorf(\"db: DependencySQLRepository.ListByIssueIDs (in): %w\", err)\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\nfunc (r *dependencySQLRepositoryImpl) CountsByIssueIDs(ctx context.Context, issueIDs []string, opts domain.DepCountsOpts) (map[string]*types.DependencyCounts, error) {\n\tresult := make(map[string]*types.DependencyCounts)\n\tif len(issueIDs) == 0 {\n\t\treturn result, nil\n\t}\n\tfor _, id := range issueIDs {\n\t\tresult[id] = &types.DependencyCounts{}\n\t}\n\n\tidPlaceholders, idArgs := buildInPlaceholders(issueIDs)\n\ttable := pickDepTable(opts.UseWispsTable)\n","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L424-L460","documentation":"Same as the (out) variant but for the incoming-direction query: SELECT ... WHERE depends_on_id IN (...), filling result.Incoming. Indicates the bulk incoming-dependency fetch failed at SQL execution or row-scan time.","triggerScenarios":"ListByIssueIDs(ctx, issueIDs, opts) with Direction=Both or In; the incoming SELECT fails or scanning rows fails: placeholder limit exceeded, connection drop, table mismatch (UseWispsTable), corrupted dep rows failing scan.","commonSituations":"Bulk exports/loads of thousands of IDs; stale wisps-table flag after migration; driver errors from NULL/typed columns changed by a schema migration.","solutions":["Chunk the issueIDs list to stay within placeholder limits.","Confirm the UseWispsTable flag matches the storage location of the deps.","Retry on a healthy connection; read-only operation.","Inspect dep rows for NULL/corrupt columns if scan errors persist after migration."],"exampleFix":"// before\nres, err := deps.ListByIssueIDs(ctx, ids, domain.DepListOpts{Direction: domain.DepDirectionIn})\n// after: chunk + both directions merged\nfor batch := range slices.Chunk(ids, 500) {\n    r, err := deps.ListByIssueIDs(ctx, batch, domain.DepListOpts{Direction: domain.DepDirectionBoth})\n    if err != nil { return err }\n    mergeInto(res, r)\n}","handlingStrategy":"validation","validationCode":"if len(issueIDs) == 0 { return domain.DepBulkResult{}, nil }\nconst maxBatch = 500\nif len(issueIDs) > maxBatch { /* chunk before calling */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"ListByIssueIDs (in)\") {\n    // retry read-only, or chunk and merge incoming maps\n}","preventionTips":["Chunk ID lists to stay within placeholder limits.","Verify the wisps-table flag matches the storage location.","Check for NULL/corrupt dep rows after schema changes (scan failures).","Retry freely — the query is read-only."],"tags":["database","query","bulk-fetch"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}