gastownhall/beads · error
applying inline expansions to %q: %w
Error message
applying inline expansions to %q: %w
What it means
Thrown in resolveAndCookFormulaWithVars when formula.ApplyInlineExpansions fails to expand inline step expansions (steps that reference other formulas inline via expansion syntax). The wrapper preserves the underlying cause while naming the formula being cooked, so failures during recursive inline expansion (parse errors, missing referenced formulas, depth problems) surface under this prefix.
Source
Thrown at cmd/bd/cook.go:748
}
}
// Apply control flow operators - loops, branches, gates
controlFlowSteps, err := formula.ApplyControlFlow(resolved.Steps, resolved.Compose)
if err != nil {
return nil, fmt.Errorf("applying control flow to %q: %w", formulaName, err)
}
resolved.Steps = controlFlowSteps
// Apply advice transformations
if len(resolved.Advice) > 0 {
resolved.Steps = formula.ApplyAdvice(resolved.Steps, resolved.Advice)
}
// Apply inline step expansions
inlineExpandedSteps, err := formula.ApplyInlineExpansions(resolved.Steps, parser)
if err != nil {
return nil, fmt.Errorf("applying inline expansions to %q: %w", formulaName, err)
}
resolved.Steps = inlineExpandedSteps
// Apply expansion operators
if resolved.Compose != nil && (len(resolved.Compose.Expand) > 0 || len(resolved.Compose.Map) > 0) {
expandedSteps, err := formula.ApplyExpansions(resolved.Steps, resolved.Compose, parser)
if err != nil {
return nil, fmt.Errorf("applying expansions to %q: %w", formulaName, err)
}
resolved.Steps = expandedSteps
}
// Apply aspects from compose.aspects
if resolved.Compose != nil && len(resolved.Compose.Aspects) > 0 {
for _, aspectName := range resolved.Compose.Aspects {
aspectFormula, err := parser.LoadByName(aspectName)
if err != nil {
return nil, fmt.Errorf("loading aspect %q: %w", aspectName, err)View on GitHub (pinned to 71377f2769)
Solutions
- Open the wrapped inner error to find the exact expansion target and failing step; fix or restore the referenced formula
- Run `bd doctor` / verify the formula search path includes the directory containing the referenced formula
- Fix typos in the inline expansion directive in the formula's YAML
- Check for circular inline expansions between formulas and break the cycle
- Re-sync the formula repository so all referenced expansion formulas exist locally
Example fix
# before (cook failing)
steps:
- id: build
use: build-and-test # formula missing from search path
# after
steps:
- id: build
use: build # corrected name, or create build-and-test formula Defensive patterns
Strategy: validation
Validate before calling
// Before cooking, verify all inline expansion targets resolve
for _, step := range f.Steps {
if step.Use != "" {
if _, err := parser.LoadByName(strings.TrimSpace(step.Use)); err != nil {
return fmt.Errorf("step %q references missing formula %q: %w", step.ID, step.Use, err)
}
}
} Try / catch
var cookErr *exitError
if err := runCook(); errors.As(err, &cookErr) && strings.Contains(err.Error(), "applying inline expansions") {
// unwrap: inspect inner cause for the missing/invalid expansion target
log.Printf("formula expansion failed: %v", errors.Unwrap(err))
} Prevention
- Run bd verify/verifyFormula on formulas after editing inline expansions
- Keep the formula search path configured so all referenced formulas resolve
- Lint formula YAML for `use:` directives pointing at existing formulas
- Watch for circular inline references when refactoring shared formulas
When it happens
Trigger: Cooking a formula whose steps use inline expansion syntax (e.g. `use formula-name` inside a step) where the referenced formula cannot be resolved, its YAML/template is malformed, or recursion exceeds allowed depth. Reached via bd cook, bd pour, verifyFormula, or resolveOrCookToSubgraph on such a formula.
Common situations: Formula library references a step-expansion formula that was renamed or deleted; a typo in the inline expansion name inside a formula YAML; circular inline references; shared formula repo not synced so an expansion target is missing locally.
Related errors
- applying inline expansions: %w
- inline expansion depth limit exceeded: max %d levels
- inline expand on step %q: loading %q: %w
- inline expand on step %q: %q is not an expansion formula (ty
- invalid variable format '%s', expected 'key=value'
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/95b4b05ea35e0736.
Report an issue: GitHub.