{"record":{"id":"7761b709f5885aea","repo":"gastownhall/beads","slug":"add-deps-d-cycle-check-w","errorCode":null,"errorMessage":"add deps[%d]: cycle check: %w","messagePattern":"add deps\\[(.+?)\\]: cycle check: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/dependency.go","lineNumber":735,"sourceCode":"\t// request. The shared repository guard can then evaluate existing + planned\n\t// ancestry without widening #4034 into #4035's combined-graph cycle check.\n\tfor phase := 0; phase < 2; phase++ {\n\t\tparentPhase := phase == 0\n\t\tfor i, dep := range deps {\n\t\t\tif (dep.Type == types.DepParentChild) != parentPhase {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := u.depRepo.ValidateBlockingHierarchy(ctx, dep); err != nil {\n\t\t\t\tvar hierarchyConflict *DependencyHierarchyConflictError\n\t\t\t\tif errors.As(err, &hierarchyConflict) {\n\t\t\t\t\treturn BulkAddDepsResult{}, err\n\t\t\t\t}\n\t\t\t\treturn BulkAddDepsResult{}, fmt.Errorf(\"add deps[%d]: hierarchy check: %w\", i, err)\n\t\t\t}\n\t\t\tif !opts.SkipPerEdgeCycleCheck && types.IsSchedulingEdge(dep.Type) {\n\t\t\t\tcycle, err := u.depRepo.HasCycle(ctx, dep.IssueID, dep.DependsOnID)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn BulkAddDepsResult{}, fmt.Errorf(\"add deps[%d]: cycle check: %w\", i, err)\n\t\t\t\t}\n\t\t\t\tif cycle {\n\t\t\t\t\treturn BulkAddDepsResult{}, cycleErrorf(\"add deps[%d]: adding %s -> %s would create a cycle\", i, dep.IssueID, dep.DependsOnID)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The explicit `bd dep add` / `bd link` verb on the proxied server\n\t\t\t// (cmd/bd/dep_proxied_server.go, link_proxied_server.go) records a\n\t\t\t// dependency_added event for each genuine new edge — unlike\n\t\t\t// create-with-deps, which calls depRepo.Insert directly without\n\t\t\t// EmitEvent. UseWispsTable routes both the edge and that event to\n\t\t\t// the source's own pair of tables.\n\t\t\t_, sourceIsWisp := wispSources[dep.IssueID]\n\t\t\tif err := u.depRepo.Insert(ctx, dep, actor, DepInsertOpts{\n\t\t\t\tUseWispsTable:      sourceIsWisp,\n\t\t\t\tHierarchyValidated: true,\n\t\t\t\tCycleValidated:     true,\n\t\t\t\tEmitEvent:          true,\n\t\t\t}); err != nil {","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/dependency.go#L717-L753","documentation":"For each scheduling edge (when SkipPerEdgeCycleCheck is false), AddDependencies calls HasCycle to test whether the proposed edge would close a cycle. This error wraps a failure of the HasCycle query itself — the cycle detection could not be executed, so the batch is aborted rather than risking an unchecked write. Note: an actual detected cycle is a different, cycleErrorf-typed error ('would create a cycle').","triggerScenarios":"Calling AddDependencies with opts.SkipPerEdgeCycleCheck=false and a scheduling dep type, when depRepo.HasCycle(ctx, IssueID, DependsOnID) returns a storage/query error.","commonSituations":"Slow or locked Dolt database during deep graph traversal; context deadline exceeded on very large dependency graphs; transient DB connection drops mid-batch.","solutions":["Inspect the wrapped error after 'cycle check:' for the storage root cause","Retry with a longer context deadline if the graph is large","If cycles are verified separately, set opts.SkipPerEdgeCycleCheck=true to rely on the final CycleThroughEdges check instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Optionally skip the per-edge probe when you pre-verified acyclicity:\nopts.SkipPerEdgeCycleCheck = true // rely on final CycleThroughEdges instead","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"cycle check\") {\n    // HasCycle query failed (not a detected cycle); inspect wrapped cause, retry\n}","preventionTips":["Distinguish detected cycles (cycleErrorf message) from check failures (this wrapper)","Use generous context deadlines for large graphs","Avoid concurrent writers during big dependency imports"],"tags":["dependencies","cycle-detection","database"],"backgroundTag":"cycle-check-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}