{"record":{"id":"9a4b4bebca51c5f5","repo":"gastownhall/beads","slug":"loading-formula-q-w","errorCode":null,"errorMessage":"loading formula %q: %w","messagePattern":"loading formula %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/cook.go","lineNumber":709,"sourceCode":"\n// resolveAndCookFormula loads a formula by name, resolves it, applies all transformations,\n// and returns an in-memory TemplateSubgraph ready for instantiation.\n// This is the main entry point for ephemeral proto cooking.\nfunc resolveAndCookFormula(formulaName string, searchPaths []string) (*TemplateSubgraph, error) {\n\treturn resolveAndCookFormulaWithVars(formulaName, searchPaths, nil)\n}\n\n// resolveAndCookFormulaWithVars loads a formula and optionally filters steps by condition.\n// If conditionVars is provided, steps with conditions that evaluate to false are excluded.\n// Pass nil for conditionVars to include all steps (condition filtering skipped).\nfunc resolveAndCookFormulaWithVars(formulaName string, searchPaths []string, conditionVars map[string]string) (*TemplateSubgraph, error) {\n\t// Create parser with search paths\n\tparser := formula.NewParser(searchPaths...)\n\n\t// Load formula by name\n\tf, err := parser.LoadByName(formulaName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"loading formula %q: %w\", formulaName, err)\n\t}\n\n\t// Resolve inheritance\n\tresolved, err := parser.Resolve(f)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolving formula %q: %w\", formulaName, err)\n\t}\n\n\t// Validate any caller-provided variable values against enum/pattern/\n\t// required-empty constraints. This is deliberately presence-agnostic:\n\t// a var missing entirely is left to the caller's own UX (e.g. bd mol\n\t// pour/wisp's missing-var hint), but a var explicitly provided with a\n\t// value that violates its constraints must error here so it reaches\n\t// every caller of this shared path (pour, wisp, mol bond, mol seed) —\n\t// runCook does not go through this helper; it validates separately via\n\t// its own formula.ValidateVars call under --mode=runtime. Previously\n\t// only that `bd cook --mode=runtime` path enforced these (mybd-u2r6).\n\tif conditionVars != nil {","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L691-L727","documentation":"The shared resolve-and-cook helper (`resolveAndCookFormulaWithVars`, used by pour, wisp, mol bond/seed, verify) wraps `parser.LoadByName` failures as `loading formula %q`. The named formula could not be found in any search path, could not be read, or failed to parse. This is the entry-point failure for every formula-name-based command.","triggerScenarios":"`bd mol pour`, `bd mol wisp`, `bd mol bond`, `bd mol seed`, or verify paths called with a formula name that does not resolve: wrong name, formula file absent from search paths (`--path` flags / default directories), unreadable file, or YAML parse error.","commonSituations":"Typos in formula names on the command line; running from a directory outside the formula search paths; formula defined only in another repo; recent rename of a formula file; missing file extension or malformed front matter breaking the parser.","solutions":["Check the formula name spelling against the actual file names in your formula directories","Run from the repo root or pass the correct search path (e.g. `--path .formula`) so the parser can find the file","Run `bd formula list` to see which formulas are discoverable","If the file exists, fix the syntax error reported by the wrapped parser error"],"exampleFix":"// before\nbd mol pour deploy-pipline\n// after\nbd mol pour deploy-pipeline","handlingStrategy":"validation","validationCode":"p := formula.NewParser(searchPaths...)\nif _, err := p.LoadByName(name); err != nil {\n    return fmt.Errorf(\"formula %q unresolvable in %v: %w\", name, searchPaths, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, os.ErrNotExist) {\n        // formula file missing: fix name or add search path\n    }\n    return fmt.Errorf(\"loading formula %q: %w\", name, err)\n}","preventionTips":["Run commands from the repo root or set explicit formula search paths","Use shell completion / bd formula list instead of typing names from memory","Commit formula files so every checkout can resolve them"],"tags":["formula","file-not-found","cli"],"backgroundTag":"formula-file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}