gastownhall/beads · error
deleting existing proto: %w
Error message
deleting existing proto: %w
What it means
When replacing an existing proto with `--force`, `bd cook` first deletes the existing proto subgraph via `deleteProtoSubgraph`. If that deletion fails (database error, dependency constraints, I/O failure), the error is wrapped as `deleting existing proto` and cook aborts before creating the replacement. This prevents a half-deleted proto state.
Source
Thrown at cmd/bd/cook.go:321
}
// Substitute variables in the formula
substituteFormulaVars(resolved, inputVars)
}
return outputJSON(resolved)
}
// persistCookFormula creates a proto bead in the database (persist mode)
func persistCookFormula(ctx context.Context, resolved *formula.Formula, protoID string, force bool, vars, bondPoints []string) error {
// Check if proto already exists
existingProto, err := store.GetIssue(ctx, protoID)
if err == nil && existingProto != nil {
if !force {
return fmt.Errorf("proto %s already exists (use --force to replace)", protoID)
}
// Delete existing proto and its children
if err := deleteProtoSubgraph(ctx, store, protoID); err != nil {
return fmt.Errorf("deleting existing proto: %w", err)
}
}
// Create the proto bead from the formula
result, err := cookFormula(ctx, store, resolved, protoID)
if err != nil {
return fmt.Errorf("cooking formula: %w", err)
}
if jsonOutput {
return outputJSON(cookResult{
ProtoID: result.ProtoID,
Formula: resolved.Formula,
Created: result.Created,
Variables: vars,
BondPoints: bondPoints,
})
}View on GitHub (pinned to 71377f2769)
Solutions
- Read the wrapped inner error for the storage-level cause and fix that first (e.g. unlock the DB, resolve the dependency)
- Run `bd doctor` to check database health
- Manually delete the stale proto subgraph (`bd delete <protoID>` including children) then re-run cook without `--force`
- Back up `.beads` storage before forced deletes; if the store is corrupted, restore from backup or re-sync
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: verify store is healthy before a forced replace
if err := bdDoctorStoreCheck(); err != nil {
return fmt.Errorf("store unhealthy before forced proto replace: %w", err)
} Try / catch
if err := deleteProtoSubgraph(ctx, store, protoID); err != nil {
// do NOT proceed to re-create; surface wrapped error and stop
return fmt.Errorf("deleting existing proto: %w", err)
} Prevention
- Run bd doctor before bulk forced-replace scripts
- Avoid concurrent bd processes writing to the same beads database
- Back up the .beads store before destructive --force operations
When it happens
Trigger: `bd cook --mode=persist --force` where `deleteProtoSubgraph` returns an error: the underlying store write fails, child issues cannot be removed due to dependency or referential problems, or the DB is locked/unavailable.
Common situations: Corrupt or locked Dolt database; a child bead referenced elsewhere blocks deletion; disk or permission problems affecting the `.beads` storage; concurrent `bd` processes writing simultaneously.
Related errors
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/f94b260f00881a1c.
Report an issue: GitHub.