{"record":{"id":"bd6c774d71cbea29","repo":"mikefarah/yq","slug":"lua-encoder-nyi-s","errorCode":null,"errorMessage":"lua encoder NYI -- %s","messagePattern":"lua encoder NYI -- (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/encoder_lua.go","lineNumber":306,"sourceCode":"\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn writeString(writer, fmt.Sprintf(\"%d\", octalValue))\n\t\t\t}\n\t\t\treturn writeString(writer, strings.ToLower(node.Value))\n\t\tcase \"!!float\":\n\t\t\tswitch strings.ToLower(node.Value) {\n\t\t\tcase \".inf\", \"+.inf\":\n\t\t\t\treturn writeString(writer, \"(1/0)\")\n\t\t\tcase \"-.inf\":\n\t\t\t\treturn writeString(writer, \"(-1/0)\")\n\t\t\tcase \".nan\":\n\t\t\t\treturn writeString(writer, \"(0/0)\")\n\t\t\tdefault:\n\t\t\t\treturn writeString(writer, node.Value)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"lua encoder NYI -- %s\", node.Tag)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"lua encoder NYI -- %s\", node.Tag)\n\t}\n}\n\nfunc (le *luaEncoder) encodeTopLevel(writer io.Writer, node *CandidateNode) error {\n\terr := writeString(writer, le.docPrefix)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = le.encodeAny(writer, node)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn writeString(writer, le.docSuffix)\n}\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/encoder_lua.go#L288-L324","documentation":"The Lua encoder hits a CandidateNode whose YAML tag it has no case for inside a scalar-tag switch, so it returns 'lua encoder NYI' (not yet implemented) naming the tag. It is a guard against emitting invalid Lua for exotic/unknown tags (custom types, timestamps, merge keys, etc.).","triggerScenarios":"Encoding a document containing a node with an unhandled tag (e.g. `!!timestamp`-derived custom type, `!!binary`, or a custom `!!set` style tag) through encodeAny when the node is not one of the handled scalar kinds/tags; reached from encodeArray, encodeMap, or encodeTopLevel.","commonSituations":"Converting YAML with custom type tags (e.g. `!!python/object` style tags, `!!binary` blobs) to Lua; documents produced by other tools that attach custom tags; round-tripping YAML with `!!merge` keys.","solutions":["Strip or normalize the unsupported tag first: `yq -o lua '(.[] | select(tag != \"!!str\")) |= (. tag=\"!!str\")'` or pipe the whole doc through `... |= tostring` where appropriate.","Use `tag` operator to inspect which tag triggers it, then `.|=\"tag value\"` to replace it with a plain scalar.","Encode to a supported format (yaml/json) if the document relies on custom tags.","If the tag is common and genuinely unsupported, file/patch an upstream case in encoder_lua.go."],"exampleFix":"# before\nyq -o lua '.' data.yaml   # data has a !!binary value\n\n# after\nyq -o lua '(.[] | select(tag == \"!!binary\")) |= (. value=\"binary data\")' data.yaml","handlingStrategy":"type-guard","validationCode":"yq '[.. | tag] | unique' file.yaml   # inspect all tags before -o lua","typeGuard":"guard() { yq -e 'all(tag == \"!!str\" or tag == \"!!int\" or tag == \"!!float\" or tag == \"!!bool\" or tag == \"!!null\" or tag == \"!!map\" or tag == \"!!seq\")' \"$1\"; }","tryCatchPattern":"if ! yq -o lua '.' file.yaml > out.lua 2>err.txt; then echo \"Lua encode failed: $(cat err.txt)\"; fi","preventionTips":["Avoid custom type tags in documents destined for Lua","Run `tag` queries to inventory exotic tags before encoding","Normalize with `|= tostring` on suspicious values"],"tags":["lua","encoder","tag","not-implemented"],"backgroundTag":"encoder-unsupported-tag","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"}