gastownhall/beads · error

loading molecule: %w

Error message

loading molecule: %w

What it means

Wrapped error from loadTemplateSubgraph when loading the resolved molecule's full issue/dependency subgraph during `bd mol squash`. The molecule ID resolved fine, but reading its child issues and edges from storage failed, aborting the squash transaction.

Source

Thrown at cmd/bd/mol_proxied_server.go:487

				return outputJSON(SquashResult{MoleculeID: moleculeID, SquashedCount: 0})
			}
			fmt.Printf("No ephemeral children found for molecule %s\n", moleculeID)
			return nil
		}
		renderSquashDryRun(moleculeID, subgraph, wispChildren, in.keepChildren)
		return nil
	}

	result, err := uow.RunTxResult(ctx, uowProvider, func(ctx context.Context, uw uow.UnitOfWork) (*SquashResult, string, error) {
		w := newUOWMolWriter(uw)

		moleculeID, err := utils.ResolvePartialID(ctx, w, in.moleculeArg)
		if err != nil {
			return nil, "", fmt.Errorf("resolving molecule ID %s: %w", in.moleculeArg, err)
		}
		subgraph, err := loadTemplateSubgraph(ctx, w, moleculeID)
		if err != nil {
			return nil, "", fmt.Errorf("loading molecule: %w", err)
		}
		wispChildren := wispChildrenOf(subgraph)
		if len(wispChildren) == 0 {
			return &SquashResult{MoleculeID: moleculeID, SquashedCount: 0}, "", nil
		}

		result, err := squashMoleculeInto(ctx, w, subgraph.Root, wispChildren, in.keepChildren, in.summary, actor)
		if err != nil {
			return nil, "", fmt.Errorf("squashing molecule: %w", err)
		}
		return result, fmt.Sprintf("bd: mol squash %s", moleculeID), nil
	})
	if err != nil {
		return HandleErrorRespectJSON("%v", err)
	}

	if result.SquashedCount == 0 && result.DigestID == "" {
		if jsonOutput {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped inner error to distinguish not-found children from I/O failures
  2. Run `bd doctor` to detect and repair broken dependency references
  3. Run `bd dolt pull` to sync missing child issues created elsewhere
  4. Retry the squash once the database is consistent
Defensive patterns

Strategy: validation

Validate before calling

// Verify the molecule's children are all present before squashing
bd mol show <molID>
bd doctor   // detects dangling dependency references

Try / catch

if err := runMolSquashProxiedServer(ctx, molID); err != nil {
    if strings.Contains(err.Error(), "loading molecule") {
        // repair then retry
        exec.Command("bd", "doctor").Run()
        err = runMolSquashProxiedServer(ctx, molID)
    }
}

Prevention

When it happens

Trigger: Run `bd mol squash <molID>` where the ID resolves but loadTemplateSubgraph fails: storage read error, missing child issues referenced by dependencies (corrupt/unsynced DB), or transaction-level driver failure.

Common situations: Partially synced Dolt database where dependency edges reference issues not yet pulled; `bd doctor`-detectable corruption; transient storage errors; children deleted out-of-band while edges remain.

Related errors


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