mikefarah/yq · error

no support for input format

Error message

no support for input format

What it means

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'.

Source

Thrown at pkg/yqlib/operator_encoder_decoder.go:106

		}

		results.PushBack(candidate.CreateReplacement(ScalarNode, "!!str", stringValue))
	}
	return context.ChildContext(results), nil
}

type decoderPreferences struct {
	format *Format
}

/* takes a string and decodes it back into an object */
func decodeOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {

	preferences := expressionNode.Operation.Preferences.(decoderPreferences)

	decoder := preferences.format.DecoderFactory()
	if decoder == nil {
		return Context{}, errors.New("no support for input format")
	}

	var results = list.New()
	for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
		candidate := el.Value.(*CandidateNode)

		context.SetVariable("decoded: "+candidate.GetKey(), candidate.AsList())

		log.Debugf("got: [%v]", candidate.Value)

		err := decoder.Init(strings.NewReader(candidate.Value))
		if err != nil {
			return Context{}, err
		}

		node, errorReading := decoder.Decode()
		if errorReading != nil {
			return Context{}, errorReading

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Check which formats your binary supports and use a supported input format (e.g. `-p yaml`, `-p json`).
  2. 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.
  3. 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.

Example fix

// before (slim build without xml decoder)
./yq -p xml '.' file.xml
// error: no support for input format
// after: rebuild with the format enabled, or use a supported input
./yq -p yaml '.' file.yaml
Defensive patterns

Strategy: validation

Validate before calling

// Go: verify the format supports decoding before selecting it
func supportsDecode(f *yqlib.Format) bool { return f != nil && f.DecoderFactory != nil }
// CLI equivalent: check `yq --help` lists the input format before scripting against it

Type guard

if f.DecoderFactory == nil {
    return fmt.Errorf("format %q cannot decode input", f.FormalName)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05). Data as JSON: /api/errors/83e1ca28fd51b900. Report an issue: GitHub.