mikefarah/yq · error

'i' is not a valid option for match. To ignore case, use an

Error message

'i' is not a valid option for match. To ignore case, use an expression like match("(?i)cat")

What it means

extractMatchArguments parses the optional params string of match/capture/test (e.g. match(exp; params)). After stripping 'g' (global), any remaining 'i' is explicitly rejected: Go's regexp supports inline case-insensitive flags, so the canonical fix the error prescribes is to embed (?i) in the pattern rather than pass an 'i' param.

Source

Thrown at pkg/yqlib/operator_strings.go:410

	// we got given parameters e.g. match(exp; params)
	if expressionNode.RHS.Operation.OperationType == blockOpType {
		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

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Use an inline flag in the pattern: match("(?i)cat")
  2. Keep 'g' if you need all matches: match("(?i)cat"; "g")
  3. Remove 'i' from the params argument entirely
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/yqlib/operator_strings.go:410 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/1e22bcde3c9a45e9. Report an issue: GitHub.