{"record":{"id":"e82e0def1764fe41","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-listbyissueids-out","errorCode":null,"errorMessage":"db: DependencySQLRepository.ListByIssueIDs (out): %w","messagePattern":"db: DependencySQLRepository\\.ListByIssueIDs \\(out\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":430,"sourceCode":"\t\tIncoming: make(map[string][]*types.Dependency),\n\t}\n\tif len(issueIDs) == 0 {\n\t\treturn result, nil\n\t}\n\n\tidPlaceholders, idArgs := buildInPlaceholders(issueIDs)\n\ttypeWhere, typeArgs := buildTypeFilter(opts.Types)\n\ttable := pickDepTable(opts.UseWispsTable)\n\n\tif opts.Direction == domain.DepDirectionBoth || opts.Direction == domain.DepDirectionOut {\n\t\t//nolint:gosec // G201: table and depSelectColumns are hardcoded\n\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","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L412-L448","documentation":"Wraps a failure from the outgoing-direction dependency listing query in ListByIssueIDs (SELECT ... WHERE issue_id IN (...)), executed via queryDeps into result.Outgoing. It means the bulk outgoing-deps fetch for the given issue IDs failed at the SQL/scan level.","triggerScenarios":"ListByIssueIDs(ctx, issueIDs, opts) with Direction=Both or Out; the SELECT fails or row scanning fails: too many IDs for the driver's placeholder limit, connection error, scan type mismatch, or wrong table via UseWispsTable.","commonSituations":"Passing thousands of issue IDs blowing past driver placeholder limits; querying the wisps deps table when data lives in the issues deps table; DB restarted mid-batch; schema drift after upgrade.","solutions":["Chunk issueIDs into batches (e.g. 500-1000) to stay within driver placeholder limits.","Verify opts.UseWispsTable selects the table that actually holds the dependencies.","Re-run on a healthy connection; it's read-only and safe to retry.","Check scan/column mismatch after schema migrations; rebuild or migrate the deps table if columns changed."],"exampleFix":"// before\nres, err := deps.ListByIssueIDs(ctx, allThousandIDs, domain.DepListOpts{Direction: domain.DepDirectionBoth})\n// after: chunk\nfor batch := range slices.Chunk(allThousandIDs, 500) {\n    r, err := deps.ListByIssueIDs(ctx, batch, domain.DepListOpts{Direction: domain.DepDirectionBoth})\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 (out)\") {\n    // retry read-only, or chunk the ID list and merge results\n}","preventionTips":["Chunk ID lists to ~500 per call to respect driver placeholder limits.","Set UseWispsTable correctly for the data you expect.","Treat it as read-only: safe to retry freely.","Run schema migrations before code that expects new dep columns."],"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"}