{"record":{"id":"f053075f2e640d20","repo":"gastownhall/beads","slug":"applying-inline-expansions-w","errorCode":null,"errorMessage":"applying inline expansions: %w","messagePattern":"applying inline expansions: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/cook.go","lineNumber":188,"sourceCode":"\t\treturn nil, fmt.Errorf(\"resolving formula: %w\", err)\n\t}\n\n\t// Apply control flow operators - loops, branches, gates\n\tcontrolFlowSteps, err := formula.ApplyControlFlow(resolved.Steps, resolved.Compose)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"applying control flow: %w\", err)\n\t}\n\tresolved.Steps = controlFlowSteps\n\n\t// Apply advice transformations\n\tif len(resolved.Advice) > 0 {\n\t\tresolved.Steps = formula.ApplyAdvice(resolved.Steps, resolved.Advice)\n\t}\n\n\t// Apply inline step expansions\n\tinlineExpandedSteps, err := formula.ApplyInlineExpansions(resolved.Steps, parser)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"applying inline expansions: %w\", err)\n\t}\n\tresolved.Steps = inlineExpandedSteps\n\n\t// Apply expansion operators\n\tif resolved.Compose != nil && (len(resolved.Compose.Expand) > 0 || len(resolved.Compose.Map) > 0) {\n\t\texpandedSteps, err := formula.ApplyExpansions(resolved.Steps, resolved.Compose, parser)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"applying expansions: %w\", err)\n\t\t}\n\t\tresolved.Steps = expandedSteps\n\t}\n\n\t// Apply aspects from compose.aspects\n\tif resolved.Compose != nil && len(resolved.Compose.Aspects) > 0 {\n\t\tfor _, aspectName := range resolved.Compose.Aspects {\n\t\t\taspectFormula, err := parser.LoadByName(aspectName)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"loading aspect %q: %w\", aspectName, err)","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L170-L206","documentation":"cmd/bd/cook.go:188 wraps errors from formula.ApplyInlineExpansions(resolved.Steps, parser), which expands steps marked for inline inclusion into their full sub-steps (embedding another formula's steps in place). It fails when an inline reference cannot be resolved: the referenced formula/step doesn't exist, can't be parsed, or the expansion recurses too deeply (self-inclusion).","triggerScenarios":"A step carries inline-expansion syntax pointing at a formula name or step id that parser cannot load (missing file/registry entry), references itself directly or transitively, or the referenced content fails to parse during expansion.","commonSituations":"Inlining a shared formula that lives only in another repo; renaming an inlined formula without updating call sites; accidentally inlining a formula that (transitively) inlines itself; a partially committed formula set where the inlined file is missing locally.","solutions":["Confirm the inline-referenced formula exists in .beads/formulas/ (or is a valid path) and parses on its own.","Check for self- or mutual-inclusion (A inlines B, B inlines A) and break the recursion.","Sync the repository so all inlined formulas are present locally.","Update stale inline references after any formula rename."],"exampleFix":"// before (step frontmatter)\ninline: shared-setup   # file never committed\n// after\ninline: .beads/formulas/shared-setup.md   # or commit shared-setup to the registry","handlingStrategy":"validation","validationCode":"func inlineRefsLoadable(steps []*formula.Step, load func(string) (*formula.Formula, error)) error {\n\tfor _, s := range steps {\n\t\tfor _, ref := range s.InlineRefs() {\n\t\t\tif _, err := load(ref); err != nil {\n\t\t\t\treturn fmt.Errorf(\"inline ref %q unloadable: %w\", ref, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func inlineRefResolvable(ref string, registry map[string]*formula.Formula) bool {\n\t_, ok := registry[ref]\n\treturn ok\n}","tryCatchPattern":"steps, err := formula.ApplyInlineExpansions(resolved.Steps, parser)\nif err != nil {\n\treturn fmt.Errorf(\"check inline references (missing file or self-inclusion): %w\", err)\n}","preventionTips":["Keep inlined formulas in the same repo/registry as their includers; never reference formulas that live only elsewhere.","Update inline references atomically with formula renames.","Avoid inline cycles: maintain a simple include graph and review it during refactors.","Run a CI job that expands every formula's inline refs before merge."],"tags":["formula","inline-expansion","recursion","reference"],"backgroundTag":"formula-inline-expansion-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}