mikefarah/yq · error

%v is not within [%v, %v]

Error message

%v is not within [%v, %v]

What it means

parseInt successfully parsed the digit string as an int64, but the result exceeds the platform int range (beyond math.MaxInt/MinInt — typically on 32-bit builds). This is a range guard in the parse helper: the numeric literal in the expression or document is too large for the native int used by callers like repeat, pick, and slice indices.

Source

Thrown at pkg/yqlib/lib.go:201

	if strings.HasPrefix(digits, "0x") ||
		strings.HasPrefix(digits, "0X") {
		num, err := strconv.ParseInt(sign+digits[2:], 16, 64)
		return "0x%X", num, err
	} else if strings.HasPrefix(digits, "0o") {
		num, err := strconv.ParseInt(sign+digits[2:], 8, 64)
		return "0o%o", num, err
	}
	num, err := strconv.ParseInt(numberString, 10, 64)
	return "%v", num, err
}

func parseInt(numberString string) (int, error) {
	_, parsed, err := parseInt64(numberString)

	if err != nil {
		return 0, err
	} else if parsed > math.MaxInt || parsed < math.MinInt {
		return 0, fmt.Errorf("%v is not within [%v, %v]", parsed, math.MinInt, math.MaxInt)
	}

	return int(parsed), err
}

func processEscapeCharacters(original string) string {
	if original == "" {
		return original
	}

	var result strings.Builder
	runes := []rune(original)

	for i := 0; i < len(runes); i++ {
		if runes[i] == '\\' && i < len(runes)-1 {
			next := runes[i+1]
			switch next {
			case '\\':

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Use a smaller number that fits in a native int
  2. On 32-bit platforms, run yq on a 64-bit build where int is 64 bits
  3. For huge counts (e.g. repeat), reconsider whether the operation is practical
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/yqlib/lib.go:201 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/0b5d984bcedd9a34. Report an issue: GitHub.