{"record":{"id":"cfe9101c3376328d","repo":"gastownhall/beads","slug":"toml-w","errorCode":null,"errorMessage":"toml: %w","messagePattern":"toml: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/parser.go","lineNumber":184,"sourceCode":"\t\treturn nil, fmt.Errorf(\"json: %w\", err)\n\t}\n\n\t// Set defaults\n\tif formula.Version == 0 {\n\t\tformula.Version = 1\n\t}\n\tif formula.Type == \"\" {\n\t\tformula.Type = TypeWorkflow\n\t}\n\n\treturn &formula, nil\n}\n\n// ParseTOML parses a formula from TOML bytes.\nfunc (p *Parser) ParseTOML(data []byte) (*Formula, error) {\n\tvar formula Formula\n\tif err := toml.Unmarshal(data, &formula); err != nil {\n\t\treturn nil, fmt.Errorf(\"toml: %w\", err)\n\t}\n\n\t// Set defaults\n\tif formula.Version == 0 {\n\t\tformula.Version = 1\n\t}\n\tif formula.Type == \"\" {\n\t\tformula.Type = TypeWorkflow\n\t}\n\n\treturn &formula, nil\n}\n\n// Resolve fully resolves a formula, processing extends and expansions.\n// Returns a new formula with all inheritance applied.\nfunc (p *Parser) Resolve(formula *Formula) (*Formula, error) {\n\t// Check for cycles\n\tif p.resolvingSet[formula.Formula] {","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/parser.go#L166-L202","documentation":"Parser.ParseTOML unmarshals bytes as TOML into the Formula struct and wraps any toml.Unmarshal failure as \"toml: ...\". Thrown for syntactically invalid TOML or values whose types don't fit the Formula struct fields. Reached from ParseFile for *.formula.toml files.","triggerScenarios":"ParseFile detects the .formula.toml extension and ParseTOML rejects the bytes: bad TOML syntax (unclosed string, duplicate key, wrong table syntax) or type mismatches (version as string, steps defined as [step] instead of [[step]]).","commonSituations":"Hand-edited formula with a missing quote or bracket; using [template]/[step] (single table) where [[template]]/[[step]] (array) is required; smart quotes from a doc editor; duplicate keys after a bad merge.","solutions":["Read the toml error's line/column and fix the syntax there.","Use [[step]] / [[template]] array-of-tables syntax for repeated sections, not single [section].","Validate with a TOML parser (e.g. taplo, python tomllib) before committing.","Restore the file from git if a merge corrupted it."],"exampleFix":"// before\n[step]        // single table: only one step survives / type error\nid = \"a\"\n// after\n[[step]]\nid = \"a\"\n[[step]]\nid = \"b\"","handlingStrategy":"validation","validationCode":"// probe with a strict TOML decoder before use\nvar probe formula.Formula\nif err := toml.Unmarshal(data, &probe); err != nil {\n\treturn fmt.Errorf(\"formula TOML invalid: %w\", err)\n}\nif probe.Formula == \"\" {\n\treturn errors.New(\"formula TOML missing top-level `formula` field\")\n}","typeGuard":"func isValidFormulaTOML(data []byte) bool {\n\tvar f formula.Formula\n\treturn toml.Unmarshal(data, &f) == nil && f.Formula != \"\"\n}","tryCatchPattern":null,"preventionTips":["Validate .formula.toml files with a TOML linter (taplo, tomllib) before committing.","Use [[step]]/[[template]] array-of-tables syntax for repeated sections.","Watch for smart quotes and unclosed strings when hand-editing formulas; avoid duplicate keys after merges."],"tags":["go","toml","parse-error","formula"],"backgroundTag":"toml-parse-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}