kubernetes/kops · error

unexpected integer value: %q

Error message

unexpected integer value: %q

What it means

parseInt wraps strconv.ParseInt(str, 10, 64) failures when converting a spec string into an *int64. It fires for any value that is not a valid signed base-10 integer within int64 range. The offending string is quoted in the message.

Source

Thrown at pkg/model/awsmodel/spotinst.go:1117

	v, err := strconv.ParseBool(str)
	if err != nil {
		return nil, fmt.Errorf("unexpected boolean value: %q", str)
	}
	return &v, nil
}

func parseFloat(str string) (*float64, error) {
	v, err := strconv.ParseFloat(str, 64)
	if err != nil {
		return nil, fmt.Errorf("unexpected float value: %q", str)
	}
	return &v, nil
}

func parseInt(str string) (*int64, error) {
	v, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
		return nil, fmt.Errorf("unexpected integer value: %q", str)
	}
	return &v, nil
}

func parseTaints(taintSpecs []string) ([]*corev1.Taint, error) {
	var taints []*corev1.Taint

	for _, taintSpec := range taintSpecs {
		taint, err := parseTaint(taintSpec)
		if err != nil {
			return nil, err
		}
		taints = append(taints, taint)
	}

	return taints, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Change the quoted value to a plain integer, e.g. '16Gi' -> the byte count, '5m' -> '300'.
  2. Remove commas/underscores from large numbers: '1,000' -> '1000'.
  3. Round decimals to integers: '2.5' -> '2' (or '3').
  4. If the option is optional, remove the empty key instead of leaving ''. Check int64 overflow if the value is astronomically large.

Example fix

// before
spotinst/ocean/max-size: "1,000"
// after
spotinst/ocean/max-size: "1000"
Defensive patterns

Strategy: validation

Validate before calling

func validInt(s string) bool {
	_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)
	return err == nil
}
if !validInt(cfg.MaxSize) { return fmt.Errorf("expected plain base-10 integer, got %q", cfg.MaxSize) }

Try / catch

if n, err := parseInt(raw); err != nil {
	return fmt.Errorf("integer field %q: %w", key, err)
}

Prevention

When it happens

Trigger: buildElastigroup/buildOcean/buildLaunchSpec/buildAutoScalerOpts parse a numeric option via parseInt and the value is non-numeric, has units ('16Gi', '5m'), uses thousands separators ('1,000'), is a decimal ('2.5'), or is empty.

Common situations: Users put Kubernetes-style quantities ('16Gi') into integer spotinst options, add 'ms'/'s' units, or use a decimal where an integer is required (e.g. max count '2.5').

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/847f835c10d2c130. Report an issue: GitHub.