{"record":{"id":"19ae3f70a3c4a358","repo":"gastownhall/beads","slug":"formula-q-w","errorCode":null,"errorMessage":"formula %q: %w","messagePattern":"formula %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/cook.go","lineNumber":729,"sourceCode":"\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 {\n\t\tif err := formula.ValidateProvidedVars(resolved, conditionVars); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"formula %q: %w\", formulaName, err)\n\t\t}\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 to %q: %w\", formulaName, 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 {","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L711-L747","documentation":"Caller-provided variable values are validated by `formula.ValidateProvidedVars` against enum, pattern, and required-empty constraints; failures are wrapped as `formula %q: <detail>`. This is presence-agnostic — omitted vars are the caller's UX concern — but any var explicitly supplied that violates its declared constraint triggers this error. It applies to all shared-path callers (pour, wisp, mol bond/seed); `bd cook --mode=runtime` validates separately.","triggerScenarios":"Passing `--var name=value` where value violates the variable's declaration: value not in the declared enum, not matching the declared regex pattern, or supplied for a variable declared `required-empty`.","commonSituations":"Environment value drifting from the declared enum after a formula update (e.g. new region list); free-text values pasted where a pattern-constrained ID is expected; supplying values for vars intentionally marked required-empty; shell expansion injecting unexpected values.","solutions":["Read the constraint detail in the wrapped message and supply a value that satisfies the declared enum/pattern","Inspect the variable declaration in the formula file to see the allowed values","Update the formula's enum/pattern if the constraint is outdated for your use case","Stop passing the variable if it is declared required-empty"],"exampleFix":"// before\nbd mol pour deploy --var env=productions\n// after (enum: [dev, staging, prod])\nbd mol pour deploy --var env=prod","handlingStrategy":"validation","validationCode":"if err := formula.ValidateProvidedVars(resolved, providedVars); err != nil {\n    return fmt.Errorf(\"invalid var values: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var verr *formula.VarConstraintError\n    if errors.As(err, &verr) {\n        // show allowed enum/pattern for verr.VarName to the user\n    }\n    return err\n}","preventionTips":["Check the formula's variable declarations (enum/pattern) before scripting --var values","Source enum values from the formula docs, not free text","Update declarations when legitimate values change, rather than loosening at call sites"],"tags":["formula","variables","validation","enum"],"backgroundTag":"formula-var-validation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}