{"record":{"id":"1b030098136d43fc","repo":"gastownhall/beads","slug":"resolve-parent-s-w","errorCode":null,"errorMessage":"resolve parent %s: %w","messagePattern":"resolve parent (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/parser.go","lineNumber":244,"sourceCode":"\t\tVersion:     formula.Version,\n\t\tType:        formula.Type,\n\t\tSource:      formula.Source,\n\t\tVars:        make(map[string]*VarDef),\n\t\tSteps:       nil,\n\t\tCompose:     nil,\n\t}\n\n\t// Apply each parent in order\n\tfor _, parentName := range formula.Extends {\n\t\tparent, err := p.loadFormula(parentName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"extends %s: %w\", parentName, err)\n\t\t}\n\n\t\t// Resolve parent recursively\n\t\tparent, err = p.Resolve(parent)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve parent %s: %w\", parentName, err)\n\t\t}\n\n\t\t// Merge parent vars (parent vars are inherited, child overrides)\n\t\tfor name, varDef := range parent.Vars {\n\t\t\tif _, exists := merged.Vars[name]; !exists {\n\t\t\t\tmerged.Vars[name] = varDef\n\t\t\t}\n\t\t}\n\n\t\t// Merge parent steps (append, child steps come after)\n\t\tmerged.Steps = append(merged.Steps, parent.Steps...)\n\n\t\t// Merge parent compose rules\n\t\tmerged.Compose = mergeComposeRules(merged.Compose, parent.Compose)\n\t}\n\n\t// Apply child overrides\n\tfor name, varDef := range formula.Vars {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/parser.go#L226-L262","documentation":"After successfully loading a parent, Resolve() recursively resolves it, and any error raised inside the parent's own resolution (including deeper ancestors, cycles, or var merge problems) is re-wrapped as 'resolve parent <name>: <cause>'. This adds the ancestor chain to the error so you can tell which level of the inheritance tree failed.","triggerScenarios":"Calling Resolve on a child formula when an ancestor in its extends graph fails Resolve — e.g. a grandparent has a circular extends (1740) or a great-grandparent cannot be loaded (1741). The root cause appears innermost in the wrapped chain.","commonSituations":"Multi-level inheritance chains (base -> mid -> child) where a rename or deletion happened at the top of the chain; debugging is confusing because the failure surfaces at the child even though the broken file is an ancestor.","solutions":["Unwrap the error chain (%w wrapping) and read the innermost message — that is the actual failing formula.","Fix the root cause in the named ancestor: break the cycle (1740) or repair/locate the missing parent (1741).","Run Resolve on the suspect ancestor formula directly to reproduce the failure in isolation."],"exampleFix":"# before: child.md -> mid.md -> base.md (base.md extends mid.md)\n# error: resolve parent mid: resolve parent base: circular extends detected: ...\n\n# after: remove 'extends: [mid]' from base.md so the chain terminates","handlingStrategy":"try-catch","validationCode":"// Resolve each ancestor individually first to isolate the failure.\nfor _, name := range ancestry(f) {\n\tif pf, err := p.LoadByName(name); err == nil {\n\t\tif _, err := p.Resolve(pf); err != nil {\n\t\t\treturn fmt.Errorf\"ancestor %s is broken: %w\", name, err\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"if _, err := p.Resolve(f); err != nil {\n\t// %w chain: print err and unwrap until the root cause\n\tfor e := err; e != nil; e = errors.Unwrap(e) {\n\t\tlog.Println(e)\n\t}\n}","preventionTips":["Resolve top-level (base) formulas in CI so ancestor breakage is caught at its source.","Avoid deep multi-level inheritance chains where a single failure cascades widely.","Test each formula's resolution in isolation, not only the leaves."],"tags":["go","formula","inheritance","error-wrapping"],"backgroundTag":"formula-parent-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}