{"record":{"id":"218df99040a959b1","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-isblocked-s-w","errorCode":null,"errorMessage":"db: DependencySQLRepository.IsBlocked %s: %w","messagePattern":"db: DependencySQLRepository\\.IsBlocked (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":876,"sourceCode":"\t\treturn deps\n\t}\n\tallowed := make(map[types.DependencyType]struct{}, len(filter))\n\tfor _, t := range filter {\n\t\tallowed[t] = struct{}{}\n\t}\n\tout := make([]*types.IssueWithDependencyMetadata, 0, len(deps))\n\tfor _, d := range deps {\n\t\tif _, ok := allowed[d.DependencyType]; ok {\n\t\t\tout = append(out, d)\n\t\t}\n\t}\n\treturn out\n}\n\nfunc (r *dependencySQLRepositoryImpl) IsBlocked(ctx context.Context, issueID string, opts domain.DepListOpts) (bool, []string, error) {\n\tblocked, blockers, err := issueops.IsBlockedInTx(ctx, r.runner, issueID)\n\tif err != nil {\n\t\treturn false, nil, fmt.Errorf(\"db: DependencySQLRepository.IsBlocked %s: %w\", issueID, err)\n\t}\n\treturn blocked, blockers, nil\n}\n\nfunc (r *dependencySQLRepositoryImpl) DetectCycles(ctx context.Context) ([][]*types.Issue, error) {\n\tout, err := issueops.DetectCyclesInTx(ctx, r.runner)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"db: DependencySQLRepository.DetectCycles: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (r *dependencySQLRepositoryImpl) DetectCycleReport(ctx context.Context) (publicops.CycleReport, error) {\n\tout, err := issueops.DetectCycleReportInTx(ctx, r.runner)\n\tif err != nil {\n\t\treturn publicops.CycleReport{}, fmt.Errorf(\"db: DependencySQLRepository.DetectCycleReport: %w\", err)\n\t}\n\treturn out, nil","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L858-L894","documentation":"IsBlocked delegates to issueops.IsBlockedInTx, which queries dependencies to determine whether an issue has open blockers and returns the blocker IDs. This wrapper indicates that the underlying in-transaction blocked-status query failed; the repository is merely adding context (repository name and issue ID) to the wrapped error.","triggerScenarios":"Calling IsBlocked(ctx, issueID, opts) when the underlying query fails: missing/corrupt dependencies table, connection error, context cancellation, or driver error inside IsBlockedInTx.","commonSituations":"Database unavailable or Dolt server stopped; issue ID typed wrong (query itself usually still succeeds, so most often it is connectivity/schema); context deadline exceeded on a slow database during bulk operations.","solutions":["Unwrap the error (errors.Unwrap / %v with %+v) to see the root cause from IsBlockedInTx.","Verify database connectivity and that the schema is migrated.","Retry with a fresh context if the cause was deadline/cancellation.","Confirm the issue exists — an invalid ID can surface via the underlying query in some drivers."],"exampleFix":"// before\nblocked, blockers, err := repo.IsBlocked(ctx, id, opts)\nif err != nil { return err }\n// after: retry transient failures with a fresh context\nblocked, blockers, err := repo.IsBlocked(ctx, freshCtx, id, opts)\nif err != nil { return fmt.Errorf(\"is blocked %s: %w\", id, err) }","handlingStrategy":"try-catch","validationCode":"if err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unreachable before IsBlocked: %w\", err)\n}","typeGuard":"func isDBUnreachable(err error) bool {\n    return errors.Is(err, driver.ErrBadConn) || dberrors.IsTableNotExist(err)\n}","tryCatchPattern":"blocked, blockers, err := repo.IsBlocked(ctx, id, opts)\nif err != nil {\n    var cause error\n    errors.As(err, &cause) // inspect unwrapped driver error\n    return fmt.Errorf(\"blocked check failed for %s: %w\", id, err)\n}","preventionTips":["Ping the database before dependent operations.","Use contexts with realistic deadlines so cancellations surface as such.","Unwrap the error to distinguish connectivity vs schema causes."],"tags":["database","sql","blocked-status","wrapper"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}