{"record":{"id":"6b315e7ca98ce7e4","repo":"gastownhall/beads","slug":"add-deps-classify-sources-w","errorCode":null,"errorMessage":"add deps: classify sources: %w","messagePattern":"add deps: classify sources: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/dependency.go","lineNumber":714,"sourceCode":"\t\t// types before the hierarchy/cycle probe, so a scheduling self-edge is\n\t\t// typed as ErrSelfDependency instead of tripping HasCycle (or the final\n\t\t// CycleThroughEdges gate) and surfacing as a cycle. The message is\n\t\t// byte-identical to every other self-dep site so the proxied bulk CLI\n\t\t// (bd dep add / bd link) shows one consistent self-dependency error.\n\t\tif dep.IssueID == dep.DependsOnID {\n\t\t\treturn BulkAddDepsResult{}, fmt.Errorf(\"%w: %s cannot depend on itself\", ErrSelfDependency, dep.IssueID)\n\t\t}\n\t}\n\tsources := make([]string, 0, len(deps))\n\tfor _, dep := range deps {\n\t\tsources = append(sources, dep.IssueID)\n\t}\n\t// One query for the batch, read before the first write. Nothing an edge\n\t// write does moves a source between planes, so the answer stays true for\n\t// the rest of the unit of work.\n\twispSources, err := u.depRepo.WispSourceIDs(ctx, sources)\n\tif err != nil {\n\t\treturn BulkAddDepsResult{}, fmt.Errorf(\"add deps: classify sources: %w\", err)\n\t}\n\t// Parent-child edges must be visible before blocking edges in the same\n\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) {","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/dependency.go#L696-L732","documentation":"AddDependencies classifies the batch's source issue IDs into regular issues vs wisps (ephemeral issues) with a single batched repository query (WispSourceIDs) made before any write. This error wraps a failure of that lookup, so the root cause is a storage/repository error (query failure, DB unavailable, context canceled), not a validation problem.","triggerScenarios":"Calling AddDependencies when u.depRepo.WispSourceIDs(ctx, sources) returns an error — e.g. the Dolt database is unreachable, the connection was closed, or ctx was canceled mid-query.","commonSituations":"Running bd against a locked or corrupt .beads Dolt database; concurrent process holding a conflicting transaction; context timeout expiring during a large batch on slow storage.","solutions":["Check the wrapped root cause (%w) — usually a Dolt/driver error printed after this prefix","Verify the .beads database is accessible and not locked by another process (bd doctor)","Retry the operation with a fresh, non-expired context"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if err := ctx.Err(); err != nil { return err } // ensure live context before the call","typeGuard":null,"tryCatchPattern":"if _, err := uc.AddDependencies(ctx, deps, opts); err != nil {\n    if strings.Contains(err.Error(), \"classify sources\") {\n        // storage-layer failure; check DB health and retry\n    }\n    return err\n}","preventionTips":["Pass a fresh context with an adequate deadline","Ensure the .beads Dolt database is not locked by another process","Run bd doctor to verify storage health before large batches"],"tags":["storage","database","dependencies"],"backgroundTag":"storage-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}