gastownhall/beads · error
cooking formula: %w
Error message
cooking formula: %w
What it means
After (optionally) clearing an old proto, persist-mode cook calls `cookFormula` to materialize the formula into a new proto bead. Any failure there — store write errors, step instantiation failures, dependency creation problems — is wrapped as `cooking formula`. The proto creation itself, not loading or resolving, failed at this point.
Source
Thrown at cmd/bd/cook.go:328
// 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,
})
}
fmt.Printf("%s Cooked proto: %s\n", ui.RenderPass("✓"), result.ProtoID)
fmt.Printf(" Created %d issues\n", result.Created)
if len(vars) > 0 {
fmt.Printf(" Variables: %s\n", strings.Join(vars, ", "))
}
if len(bondPoints) > 0 {View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped inner error to identify whether it is a storage or formula-content failure
- Run `bd doctor` to verify database health and repair common issues
- Validate the formula (`bd formula validate`) to rule out malformed steps before re-running
- Retry after resolving the storage issue; if the run partially wrote beads, clean up the partial proto before re-running with `--force`
Defensive patterns
Strategy: try-catch
Validate before calling
// validate formula before persisting
if err := formula.Validate(resolved); err != nil {
return fmt.Errorf("formula invalid, refusing persist: %w", err)
} Try / catch
result, err := cookFormula(ctx, store, resolved, protoID)
if err != nil {
// partial proto may exist; clean up before retry
_ = deleteProtoSubgraph(ctx, store, protoID)
return fmt.Errorf("cooking formula: %w", err)
} Prevention
- Run bd doctor / verify store writability before persist runs in CI
- Validate formulas before cooking; avoid cooking with a degraded or locked database
- Serialize persist-mode cooks so concurrent writers can't conflict
When it happens
Trigger: `bd cook --mode=persist` where `cookFormula` fails: the store rejects bead creation (duplicate keys, DB unavailable), a step fails to instantiate, or dependency edges between created steps cannot be written.
Common situations: Dolt/database connection problems during write; formula producing invalid steps or references; resource constraints (disk full); concurrent writers conflicting in the same beads database.
Related errors
- proto %s already exists (use --force to replace)
- deleting existing proto: %w
- ErrTransaction
- ErrQuery
- ErrScan
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/d8fe8181252f37e4.
Report an issue: GitHub.