{"record":{"id":"0a5f37c603a361ac","repo":"mikefarah/yq","slug":"unsupported-array-item-kind-v","errorCode":null,"errorMessage":"unsupported array item kind: %v","messagePattern":"unsupported array item kind: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/encoder_toml.go","lineNumber":337,"sourceCode":"\t\t\tswitch it.Kind {\n\t\t\tcase ScalarNode:\n\t\t\t\titemStr = te.formatScalar(it)\n\t\t\tcase SequenceNode:\n\t\t\t\tnested, err := te.sequenceToInlineArray(it)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\titemStr = nested\n\t\t\tcase MappingNode:\n\t\t\t\tinline, err := te.mappingToInlineTable(it)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\titemStr = inline\n\t\t\tcase AliasNode:\n\t\t\t\treturn fmt.Errorf(\"aliases are not supported in TOML\")\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"unsupported array item kind: %v\", it.Kind)\n\t\t\t}\n\n\t\t\t// Always add trailing comma in multiline arrays\n\t\t\titemStr += \",\"\n\n\t\t\tif _, err := w.Write([]byte(\"  \" + itemStr + \"\\n\")); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Add blank line between elements (except after the last one)\n\t\t\tif i < len(seq.Content)-1 {\n\t\t\t\tif _, err := w.Write([]byte(\"\\n\")); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif _, err := w.Write([]byte(\"]\\n\")); err != nil {","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/encoder_toml.go#L319-L355","documentation":"writeArrayAttribute (multiline array branch) only supports scalar, sequence and mapping elements; any other node kind (e.g. an alias node that slipped past its own case, or an unexpected kind) hits the default branch. The %v is the numeric CandidateNode Kind. It indicates the array contains an element kind the TOML encoder cannot represent.","triggerScenarios":"Calling the TOML encoder on a CandidateNode sequence whose element Kind is neither ScalarNode, SequenceNode, MappingNode nor AliasNode — e.g. a document/null-kind node or internal node kinds produced by unusual expressions — when the array is rendered in multiline (element-comment) form.","commonSituations":"Programmatic use of yqlib where a raw CandidateNode tree (not from a normal decode) is encoded to TOML; documents containing nulls or exotic nodes placed inside commented arrays.","solutions":["Inspect the array contents (yq '.' input) and remove/replace the non-scalar element.","Derefence any aliases first: yq -o json then back to toml.","Ensure every array element is a concrete scalar, array, or table in the source YAML.","If using yqlib programmatically, normalize the tree (call UnwrapAliased or evaluate) before encoding."],"exampleFix":"// before\na: # comment\n  - null-ish-node   # unsupported kind\n// after\na: # comment\n  - \"explicit value\"   # scalar element","handlingStrategy":"validation","validationCode":"yq '[.. | kind] | any(. != \"scalar\" and . != \"seq\" and . != \"map\" and . != \"alias\")' in.yaml","typeGuard":"// Go\nfunc encodableKind(k yqlib.Kind) bool {\n    switch k { case yqlib.ScalarNode, yqlib.SequenceNode, yqlib.MappingNode: return true }\n    return false\n}","tryCatchPattern":"// Go\nif err := enc.EncodeTOML(node); err != nil {\n    if strings.Contains(err.Error(), \"unsupported array item kind\") {\n        // inspect/normalize offending element then re-encode\n    }\n}","preventionTips":["Ensure array elements are scalars, arrays, or tables only","Re-parse inputs through yq's decoder rather than hand-building nodes","Validate source documents with yq before converting formats"],"tags":["toml","encoder","unsupported-node-kind"],"backgroundTag":"toml-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"}