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
- Change the quoted value to a plain integer, e.g. '16Gi' -> the byte count, '5m' -> '300'.
- Remove commas/underscores from large numbers: '1,000' -> '1000'.
- Round decimals to integers: '2.5' -> '2' (or '3').
- 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
- Never use Kubernetes quantity strings ('16Gi') or unit suffixes ('5m') in integer fields; convert to raw integers first.
- No thousands separators ('1,000') or decimals ('2.5') in integer options.
- Keep values within int64 range; compute sizes in bytes explicitly if needed.
- Validate the spec YAML with a schema before `kops update cluster`.
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
- unexpected boolean value: %q
- unexpected float value: %q
- invalid taint spec: %v
- parsing additional containerd config entry %q: %w
- invalid EtcdClusterSpec (expected two tokens): %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/847f835c10d2c130.
Report an issue: GitHub.