{"record":{"id":"653cd5f891e9314e","repo":"mikefarah/yq","slug":"unsupported-node-kind-for-toml-v","errorCode":null,"errorMessage":"unsupported node kind for TOML: %v","messagePattern":"unsupported node kind for TOML: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/encoder_toml.go","lineNumber":213,"sourceCode":"\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\t// Regular array attribute\n\t\treturn te.writeArrayAttribute(w, path[len(path)-1], node)\n\tcase MappingNode:\n\t\t// Use inline table syntax only for nodes explicitly marked as TOML inline tables.\n\t\t// YAML flow-style mappings are not treated as inline tables; the FlowStyle attribute\n\t\t// is a YAML-specific rendering hint and should not affect TOML output. This ensures\n\t\t// that auto-detected JSON input (parsed as YAML flow style) produces readable table\n\t\t// sections, consistent with explicitly parsed JSON input.\n\t\tif node.EncodeHint == EncodeHintInline {\n\t\t\treturn te.writeInlineTableAttribute(w, path[len(path)-1], node)\n\t\t}\n\t\treturn te.encodeSeparateMapping(w, path, node)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported node kind for TOML: %v\", node.Kind)\n\t}\n}\n\nfunc isTomlArrayOfTables(seq *CandidateNode) bool {\n\tif len(seq.Content) == 0 {\n\t\treturn false\n\t}\n\tfor _, it := range seq.Content {\n\t\tif it.Kind != MappingNode || it.EncodeHint == EncodeHintInline {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc isTomlAttribute(node *CandidateNode) bool {\n\tif node.Kind == ScalarNode {\n\t\treturn true","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/encoder_toml.go#L195-L231","documentation":"Inside encodeTopLevelEntry, the switch over node Kind handles scalar, sequence (incl. array-of-tables), and mapping (incl. inline tables); any other Kind falls through to 'unsupported node kind for TOML: %v'. This guards against kinds TOML cannot represent at a top-level entry position.","triggerScenarios":"A root mapping whose value node has a non-scalar/seq/map Kind (typically an unresolved AliasNode or document/fragment node) is encoded with `-o toml`, falling into the default branch at encoder_toml.go:213.","commonSituations":"YAML anchors/aliases not resolved before TOML encoding; synthetic nodes built by expressions that keep document kinds; hand-built CandidateNodes via the library API.","solutions":["Resolve aliases before encoding: `yq -o toml '(.[] | select(is(\"alias\"))) |= eval'` or avoid anchors in the source.","Flatten/simplify the expression so values are plain scalars, maps, or sequences.","Preview with `-o json` to identify the offending node and normalize it (e.g. with `.|= .` dereferencing or rebuilding).","Upgrade yq — alias handling in the TOML encoder has improved over releases."],"exampleFix":"# before\nyq -o toml '.' doc.yaml   # value is an alias node -> unsupported kind\n\n# after\nyq -o toml '(.. | select(kind == \"alias\")) |= eval' doc.yaml","handlingStrategy":"type-guard","validationCode":"yq '[.. | kind] | unique' file.yaml   # look for 'alias' or unexpected kinds before -o toml","typeGuard":"hasAlias() { yq -e '[.. | kind] | any(. == \"alias\")' \"$1\" > /dev/null; }","tryCatchPattern":"yq -o toml '.' doc.yaml 2>/dev/null || yq -o toml '(.. | select(kind == \"alias\")) |= eval' doc.yaml","preventionTips":["Resolve anchors/aliases before TOML encoding","Ensure values at root entries are scalar/map/seq only","Preview kinds with the `kind` operator before encoding"],"tags":["toml","encoder","node-kind","alias"],"backgroundTag":"encoder-unsupported-node-kind","analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}