{"record":{"id":"5bf1e854a26e141a","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-getwispdependencyrecor","errorCode":null,"errorMessage":"db: DependencySQLRepository.GetWispDependencyRecordsForIDs: %w","messagePattern":"db: DependencySQLRepository\\.GetWispDependencyRecordsForIDs: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":984,"sourceCode":"\t\treturn map[string][]*types.Dependency{}, nil\n\t}\n\tout, err := issueops.GetDependencyRecordsForIssuesInTx(ctx, r.runner, issueIDs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"db: DependencySQLRepository.GetDependencyRecordsForIssues: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (r *dependencySQLRepositoryImpl) GetWispDependencyRecordsForIDs(ctx context.Context, wispIDs []string) (map[string][]*types.Dependency, error) {\n\tif len(wispIDs) == 0 {\n\t\treturn map[string][]*types.Dependency{}, nil\n\t}\n\tout, err := issueops.GetDependencyRecordsForIssuesFromTableInTx(ctx, r.runner, \"wisp_dependencies\", wispIDs)\n\tif err != nil {\n\t\tif dberrors.IsTableNotExist(err) {\n\t\t\treturn map[string][]*types.Dependency{}, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"db: DependencySQLRepository.GetWispDependencyRecordsForIDs: %w\", err)\n\t}\n\treturn out, nil\n}\n","sourceCodeStart":966,"sourceCodeEnd":988,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L966-L988","documentation":"This error wraps any failure from issueops.GetDependencyRecordsForIssuesForIDs when fetching dependency records for wisp issue IDs from the wisp_dependencies table. The repository deliberately swallows 'table not exist' (returns empty map) so this error signals a real query failure, not a missing wisps schema. The %w preserves the underlying driver error for errors.Is/As inspection.","triggerScenarios":"Calling GetWispDependencyRecordsForIDs when the underlying SQL query fails: malformed wisp IDs causing SQL errors, connection drops mid-query, lock timeouts, or an issueops helper bug. Only non-TableNotExist failures reach this wrapper.","commonSituations":"Dolt server restarted or connection pool exhausted during a batch dependency lookup; corrupt or oversized wisp ID list causing query errors; schema exists but a driver-level error (context canceled, deadlock) occurs.","solutions":["Inspect the wrapped cause with errors.Is/errors.As (e.g. context.Canceled, mysql driver errors) to identify the root failure","Verify DB connectivity and that the wisp_dependencies table exists and matches expected schema (bd migrate / dolt schema check)","Retry with fewer IDs if the batch is very large (query size/placeholder limits)","Check for lock contention from concurrent transactions on wisp_dependencies"],"exampleFix":"// before\nout, err := repo.GetWispDependencyRecordsForIDs(ctx, hugeIDList)\n// after\nout, err := repo.GetWispDependencyRecordsForIDs(ctx, ctxValue, chunkIDs(ids, 500))","handlingStrategy":"try-catch","validationCode":"if len(wispIDs) == 0 { return map[string][]*types.Dependency{} }\nfor _, id := range wispIDs {\n    if id == \"\" { return fmt.Errorf(\"empty wisp ID\") }\n}","typeGuard":"func isTableNotExistErr(err error) bool { return dberrors.IsTableNotExist(err) }\nfunc isTransientDBErr(err error) bool {\n    return errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF)\n}","tryCatchPattern":"out, err := repo.GetWispDependencyRecordsForIDs(ctx, ids)\nif err != nil {\n    var derr *go_mysql.MySQLError\n    if errors.As(err, &derr) {\n        log.Errorf(\"dependency lookup failed (code %d): %v\", derr.Number, derr)\n    }\n    if isTransientDBErr(err) { retryWithBackoff() }\n    return fmt.Errorf(\"fetching dependencies: %w\", err)\n}","preventionTips":["Validate and deduplicate ID lists before batching","Keep context timeouts generous enough for large ID sets","Ensure schema migrations have run so wisp tables exist","Monitor connection pool health"],"tags":["database","dolt","dependencies","wisps"],"backgroundTag":"db-query-wrapped-failure","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}