kubernetes/kops · error

unexpected float value: %q

Error message

unexpected float value: %q

What it means

parseFloat wraps strconv.ParseFloat(str, 64) failures when a spec string is converted to a *float64. It fires for any value that is not a valid base-10 float (e.g. '50%', '1,5', 'low', or an empty string). The offending string is quoted in the message.

Source

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

		opt.HTTPPutResponseHopLimit = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit))
		opt.HTTPTokens = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens))
		return opt
	}
	return nil
}

func parseBool(str string) (*bool, error) {
	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 {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Fix the quoted value in the error to a plain decimal number, e.g. '50%' -> '50', '0,9' -> '0.9'.
  2. Use '.' as the decimal separator, never ','.
  3. Remove surrounding whitespace/quotes from the value.
  4. If the field is optional, remove the key entirely instead of leaving an empty string.

Example fix

// before
spotinst/ocean/autoscaler/scale-down-utilization-threshold: "50%"
// after
spotinst/ocean/autoscaler/scale-down-utilization-threshold: "0.5"
Defensive patterns

Strategy: validation

Validate before calling

func validFloat(s string) bool {
	_, err := strconv.ParseFloat(strings.TrimSpace(s), 64)
	return err == nil
}
if !validFloat(cfg.Threshold) { return fmt.Errorf("expected decimal number with '.' separator, got %q", cfg.Threshold) }

Try / catch

if f, err := parseFloat(raw); err != nil {
	return fmt.Errorf("numeric field %q: %w", key, err)
}

Prevention

When it happens

Trigger: buildElastigroup or buildAutoScalerOpts reads a numeric config key (e.g. a percentage or ratio field) via parseFloat and the value cannot be parsed: '50%', '0,9', 'auto', or blank.

Common situations: Users enter percentages with a % sign, use comma as decimal separator (locale-dependent editors), or leave a placeholder like 'TBD' in the spotinst numeric option.

Related errors


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