{"record":{"id":"83e1ca28fd51b900","repo":"mikefarah/yq","slug":"no-support-for-input-format","errorCode":null,"errorMessage":"no support for input format","messagePattern":"no support for input format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_encoder_decoder.go","lineNumber":106,"sourceCode":"\t\t}\n\n\t\tresults.PushBack(candidate.CreateReplacement(ScalarNode, \"!!str\", stringValue))\n\t}\n\treturn context.ChildContext(results), nil\n}\n\ntype decoderPreferences struct {\n\tformat *Format\n}\n\n/* takes a string and decodes it back into an object */\nfunc decodeOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {\n\n\tpreferences := expressionNode.Operation.Preferences.(decoderPreferences)\n\n\tdecoder := preferences.format.DecoderFactory()\n\tif decoder == nil {\n\t\treturn Context{}, errors.New(\"no support for input format\")\n\t}\n\n\tvar results = list.New()\n\tfor el := context.MatchingNodes.Front(); el != nil; el = el.Next() {\n\t\tcandidate := el.Value.(*CandidateNode)\n\n\t\tcontext.SetVariable(\"decoded: \"+candidate.GetKey(), candidate.AsList())\n\n\t\tlog.Debugf(\"got: [%v]\", candidate.Value)\n\n\t\terr := decoder.Init(strings.NewReader(candidate.Value))\n\t\tif err != nil {\n\t\t\treturn Context{}, err\n\t\t}\n\n\t\tnode, errorReading := decoder.Decode()\n\t\tif errorReading != nil {\n\t\t\treturn Context{}, errorReading","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_encoder_decoder.go#L88-L124","documentation":"yq's decodeOperator runs the `from_...`/input-format decode step against the format selected in the expression's decoderPreferences. Each Format may have a nil DecoderFactory (e.g. encode-only formats or builds compiled with `yq_no<format>` tags that stub the factory out). When the factory is nil, yq cannot produce a decoder and returns 'no support for input format'.","triggerScenarios":"Calling yq with an input format whose Format entry has DecoderFactory()==nil — typically using `-p <format>`/`--input-format` for a format that is encode-only, or using a binary built with build tags like `yq_nojson`, `yq_noxml` etc. that replaced the decoder factory with a nil-returning stub.","commonSituations":"Running a slim/small yq build (tinygo or `build_small-yq.sh` output) where the needed format was compiled out; using an encode-only format as input; typo'd or aliased format name resolving to a stub format.","solutions":["Check which formats your binary supports and use a supported input format (e.g. `-p yaml`, `-p json`).","Rebuild yq without the restrictive build tag (avoid `yq_no<format>` tags / use the full build) so the decoder for that format is compiled in.","If you control the code, register a DecoderFactory for the Format before calling decodeOperator, or guard with `if f.DecoderFactory == nil` before selecting the format."],"exampleFix":"// before (slim build without xml decoder)\n./yq -p xml '.' file.xml\n// error: no support for input format\n// after: rebuild with the format enabled, or use a supported input\n./yq -p yaml '.' file.yaml","handlingStrategy":"validation","validationCode":"// Go: verify the format supports decoding before selecting it\nfunc supportsDecode(f *yqlib.Format) bool { return f != nil && f.DecoderFactory != nil }\n// CLI equivalent: check `yq --help` lists the input format before scripting against it","typeGuard":"if f.DecoderFactory == nil {\n    return fmt.Errorf(\"format %q cannot decode input\", f.FormalName)\n}","tryCatchPattern":null,"preventionTips":["Use full (non-tagged) yq builds in production scripts","Pin the yq version used by CI so format availability is stable","Assert format support in scripts before processing user-supplied files"],"tags":["go","yq","decoder","build-tags"],"backgroundTag":"unsupported-input-format","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"}