{"record":{"id":"0634f4650b3c65e1","repo":"gastownhall/beads","slug":"map-loading-q-w","errorCode":null,"errorMessage":"map: loading %q: %w","messagePattern":"map: loading %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/expand.go","lineNumber":109,"sourceCode":"\t\texpanded[rule.Target] = true\n\n\t\t// Update dependencies: any step that depended on the target should now\n\t\t// depend on the last step of the expansion\n\t\tif len(expandedSteps) > 0 {\n\t\t\tlastStepID := expandedSteps[len(expandedSteps)-1].ID\n\t\t\tresult = UpdateDependenciesForExpansion(result, rule.Target, lastStepID)\n\t\t}\n\n\t\t// Rebuild stepMap from result so subsequent iterations see resolved deps\n\t\tstepMap = buildStepMap(result)\n\t}\n\n\t// Apply map rules (pattern matching)\n\tfor _, rule := range compose.Map {\n\t\t// Load the expansion formula\n\t\texpFormula, err := parser.LoadByName(rule.With)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"map: loading %q: %w\", rule.With, err)\n\t\t}\n\n\t\tif expFormula.Type != TypeExpansion {\n\t\t\treturn nil, fmt.Errorf(\"map: %q is not an expansion formula (type=%s)\", rule.With, expFormula.Type)\n\t\t}\n\n\t\tif len(expFormula.Template) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"map: %q has no template steps\", rule.With)\n\t\t}\n\n\t\t// Merge formula default vars with rule overrides\n\t\tvars := mergeVars(expFormula, rule.Vars)\n\n\t\t// Find all matching steps (including nested children)\n\t\t// Rebuild stepMap to capture any changes from previous expansions\n\t\tstepMap = buildStepMap(result)\n\t\tvar toExpand []*Step\n\t\tfor id, step := range stepMap {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/expand.go#L91-L127","documentation":"Wraps the error from parser.LoadByName while loading the formula referenced by a compose `map` rule. The formula name in `with:` could not be resolved or failed to load/parse; the underlying loader error is preserved.","triggerScenarios":"ApplyExpansions processes compose.Map rules and parser.LoadByName(rule.With) fails — formula not found in search paths, file unreadable, or parse error.","commonSituations":"Typo in the `with:` formula name; formula file missing from the search path; formula directory not registered; syntax error inside the formula file.","solutions":["Fix the formula name in the map rule's `with:` to match an existing expansion formula","Ensure the formula file exists in a registered formula search path","Fix syntax/parse errors reported in the wrapped loader error"],"exampleFix":"# before\nmap:\n  - select: \"gen-*\"\n    with: matrix_expan  # typo\n# after\nmap:\n  - select: \"gen-*\"\n    with: matrix-expand","handlingStrategy":"validation","validationCode":"for _, rule := range compose.Map {\n    if _, err := parser.LoadByName(rule.With); err != nil {\n        return fmt.Errorf(\"map rule with=%q cannot load: %w\", rule.With, err)\n    }\n}","typeGuard":"func formulaExists(name string) bool { _, err := parser.LoadByName(name); return err == nil }","tryCatchPattern":"expanded, err := formula.ApplyExpansions(steps, compose)\nif err != nil && strings.Contains(err.Error(), \"map: loading\") {\n    return fmt.Errorf(\"check map rule `with:` names and formula search paths: %w\", err)\n}","preventionTips":["Keep formula names consistent (kebab-case, single convention)","Register all formula directories in the search path before applying composes","Run a preflight load of every `with:` reference in CI"],"tags":["formula","map","not-found"],"backgroundTag":"formula-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}