{"record":{"id":"b22ddcb20d8bde94","repo":"gastownhall/beads","slug":"db-dependencysqlrepository-insert-mark-is-blocke","errorCode":null,"errorMessage":"db: DependencySQLRepository.Insert: mark is_blocked: %w","messagePattern":"db: DependencySQLRepository\\.Insert: mark is_blocked: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/dependency.go","lineNumber":210,"sourceCode":"\t// target spawner), then a Mark pass propagates blocked state — or, for\n\t// parent-child adds (not monotonic: an already-closed child can satisfy an\n\t// any-children waits-for gate), a full mark/unmark Recompute. Skipping the\n\t// expansion left descendants stale when a blocking edge landed on their\n\t// ancestor (bd-6dnrw.44 item 3).\n\tsrcIsWisp := opts.UseWispsTable\n\tvar affectedIssues, affectedWisps []string\n\tvar aerr error\n\tif srcIsWisp {\n\t\taffectedIssues, affectedWisps, aerr = issueops.AffectedByDepChangeForWispInTx(ctx, r.runner, dep.IssueID, dep.DependsOnID, dep.Type)\n\t} else {\n\t\taffectedIssues, affectedWisps, aerr = issueops.AffectedByDepChangeInTx(ctx, r.runner, dep.IssueID, dep.DependsOnID, dep.Type)\n\t}\n\tif aerr != nil {\n\t\treturn fmt.Errorf(\"db: DependencySQLRepository.Insert: affected set: %w\", aerr)\n\t}\n\tif dep.Type == types.DepBlocks || dep.Type == types.DepConditionalBlocks {\n\t\tif err := r.markDirectBlockedSource(ctx, dep.IssueID, srcIsWisp, dep.DependsOnID, targetCol); err != nil {\n\t\t\treturn fmt.Errorf(\"db: DependencySQLRepository.Insert: mark is_blocked: %w\", err)\n\t\t}\n\t\taffectedIssues, affectedWisps = issueops.RemoveSourceFromAffected(dep.IssueID, srcIsWisp, affectedIssues, affectedWisps)\n\t}\n\tif dep.Type == types.DepParentChild {\n\t\tif err := issueops.RecomputeIsBlockedInTx(ctx, r.runner, affectedIssues, affectedWisps); err != nil {\n\t\t\treturn fmt.Errorf(\"db: DependencySQLRepository.Insert: recompute is_blocked: %w\", err)\n\t\t}\n\t\t// Snapshot only after all derived blocked-state maintenance has completed.\n\t\treturn issueops.RecordDepEventInTx(ctx, r.runner, issueops.EventDepAdd, dep.IssueID, string(dep.Type), dep.DependsOnID, metadata, actor)\n\t}\n\tif err := issueops.MarkIsBlockedInTx(ctx, r.runner, affectedIssues, affectedWisps); err != nil {\n\t\treturn fmt.Errorf(\"db: DependencySQLRepository.Insert: mark is_blocked (affected): %w\", err)\n\t}\n\t// Snapshot only after all derived blocked-state maintenance has completed.\n\t// Never gated on opts.EmitEvent: a structurally-wired edge is as real to a\n\t// replaying consumer as one added by an explicit dep verb.\n\treturn issueops.RecordDepEventInTx(ctx, r.runner, issueops.EventDepAdd, dep.IssueID, string(dep.Type), dep.DependsOnID, metadata, actor)\n}","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/dependency.go#L192-L228","documentation":"This error wraps a failure from markDirectBlockedSource, which flags the source issue as directly blocked after adding a blocks/conditional-blocks edge. The edge insert succeeded but the direct is_blocked marker update failed.","triggerScenarios":"Calling Insert with dep.Type = DepBlocks or DepConditionalBlocks where markDirectBlockedSource's UPDATE of the source issue's is_blocked flag fails (driver error, missing column, connection loss).","commonSituations":"Schema drift on issues/wisps is_blocked columns; connection dropped between insert and mark; read-only backend.","solutions":["Check connectivity and retry; re-running Insert is safe for same-type edges (idempotent metadata refresh).","Verify is_blocked columns exist in the current schema (bd doctor).","Run a blocked-state recompute to repair stale flags after the failure.","Inspect the wrapped driver error for the failing statement."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := repo.Insert(ctx, dep, actor, opts); err != nil {\n    if strings.Contains(err.Error(), \"mark is_blocked\") && !strings.Contains(err.Error(), \"(affected)\") {\n        // direct mark failed; retry and verify is_blocked state\n    }\n}","preventionTips":["Migrate schema before version upgrades.","Retry with backoff on transient failures.","Run periodic blocked-state recomputes to self-heal."],"tags":["database","is-blocked","blocks"],"backgroundTag":"blocked-state-mark-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}