gastownhall/beads · error

applyGraph: read existing deps for %s: %w

Error message

applyGraph: read existing deps for %s: %w

What it means

Wraps a failure from depRepo.ListByIssueIDs (regular dependencies table) while graphHasPath lazily loads a node's existing outgoing deps during dependency-graph cycle detection. The underlying store/query error is chained as %w. Thrown during ApplyGraph when the walk visits a node not yet in the dep cache.

Source

Thrown at internal/storage/domain/issue.go:1533

		}
		if seen[id] {
			return false, nil
		}
		seen[id] = true
		for _, next := range adj[id] {
			found, err := visit(next)
			if err != nil || found {
				return found, err
			}
		}
		deps, ok := depCache[id]
		if !ok {
			regular, err := u.depRepo.ListByIssueIDs(ctx, []string{id}, DepListOpts{
				Direction:     DepDirectionOut,
				UseWispsTable: false,
			})
			if err != nil {
				return false, fmt.Errorf("applyGraph: read existing deps for %s: %w", id, err)
			}
			wisp, err := u.depRepo.ListByIssueIDs(ctx, []string{id}, DepListOpts{
				Direction:     DepDirectionOut,
				UseWispsTable: true,
			})
			if err != nil {
				return false, fmt.Errorf("applyGraph: read existing wisp deps for %s: %w", id, err)
			}
			deps = append(regular.Outgoing[id], wisp.Outgoing[id]...)
			depCache[id] = deps
		}
		for _, dep := range deps {
			if !followExistingDep(dep.Type) {
				continue
			}
			found, err := visit(dep.DependsOnID)
			if err != nil || found {
				return found, err

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check database connectivity and retry the bd command (transient driver errors often clear).
  2. Inspect the wrapped %w error for the concrete storage error; fix storage-level cause (e.g. restart dolt server).
  3. Verify deps table schema matches the expected version (bd doctor / driver migration).
  4. Reduce graph size or raise context timeout if deadline-exceeded.
Defensive patterns

Strategy: retry

Validate before calling

// ensure the issue id is resolvable before applying the graph
if id == "" {
    return fmt.Errorf("graph node id is empty")
}
if err := ctx.Err(); err != nil {
    return err
}

Try / catch

if err != nil {
    var retryable bool
    if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, driver.ErrUnavailable) {
        retryable = true
    }
    return fmt.Errorf("applyGraph: read existing deps for %s: %w (retryable=%v)", id, err, retryable)
}

Prevention

When it happens

Trigger: ApplyGraph cycle-check walk reaches a node whose outgoing deps are not cached and the non-wisp ListByIssueIDs query fails (DB unavailable, bad connection, storage driver error, corrupted deps table, context canceled).

Common situations: Dolt/database process down mid-command; network partition to remote Dolt; ctx deadline exceeded on very large dependency graphs; table schema drift after version upgrade.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/f9e59cb9ac9b8ffa. Report an issue: GitHub.