mikefarah/yq · error

unrecognised match params '%v', please see docs at https://m

Error message

unrecognised match params '%v', please see docs at https://mikefarah.gitbook.io/yq/operators/string-operators

What it means

After extractMatchArguments consumed the recognised params ('g', and rejecting 'i'), characters remain in the params string of match/capture/test. Only 'g' is a valid parameter — anything else (typos like 'global', 'm', 'n') makes the whole params argument unrecognised, and the error links to the string-operators docs.

Source

Thrown at pkg/yqlib/operator_strings.go:413

		block := expressionNode.RHS
		regExExpNode = block.LHS
		replacementNodes, err := d.GetMatchingNodes(context, block.RHS)
		if err != nil {
			return nil, matchPrefs, err
		}
		paramText := ""
		if replacementNodes.MatchingNodes.Front() != nil {
			paramText = replacementNodes.MatchingNodes.Front().Value.(*CandidateNode).Value
		}
		if strings.Contains(paramText, "g") {
			paramText = strings.ReplaceAll(paramText, "g", "")
			matchPrefs.Global = true
		}
		if strings.Contains(paramText, "i") {
			return nil, matchPrefs, fmt.Errorf(`'i' is not a valid option for match. To ignore case, use an expression like match("(?i)cat")`)
		}
		if len(paramText) > 0 {
			return nil, matchPrefs, fmt.Errorf(`unrecognised match params '%v', please see docs at https://mikefarah.gitbook.io/yq/operators/string-operators`, paramText)
		}
	}

	regExNodes, err := d.GetMatchingNodes(context.ReadOnlyClone(), regExExpNode)
	if err != nil {
		return nil, matchPrefs, err
	}
	log.Debug(NodesToString(regExNodes.MatchingNodes))
	regExStr := ""
	if regExNodes.MatchingNodes.Front() != nil {
		regExStr = regExNodes.MatchingNodes.Front().Value.(*CandidateNode).Value
	}
	log.Debugf("regEx %v", regExStr)
	regEx, err := regexp.Compile(regExStr)
	return regEx, matchPrefs, err
}

func matchOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Use only the supported param 'g' for global matching
  2. For case-insensitivity, put (?i) in the regex itself instead of a param
  3. Drop the params argument entirely if none is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/yqlib/operator_strings.go:413 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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