{"record":{"id":"847f835c10d2c130","repo":"kubernetes/kops","slug":"unexpected-integer-value-q","errorCode":null,"errorMessage":"unexpected integer value: %q","messagePattern":"unexpected integer value: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":1117,"sourceCode":"\tv, err := strconv.ParseBool(str)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected boolean value: %q\", str)\n\t}\n\treturn &v, nil\n}\n\nfunc parseFloat(str string) (*float64, error) {\n\tv, err := strconv.ParseFloat(str, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected float value: %q\", str)\n\t}\n\treturn &v, nil\n}\n\nfunc parseInt(str string) (*int64, error) {\n\tv, err := strconv.ParseInt(str, 10, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected integer value: %q\", str)\n\t}\n\treturn &v, nil\n}\n\nfunc parseTaints(taintSpecs []string) ([]*corev1.Taint, error) {\n\tvar taints []*corev1.Taint\n\n\tfor _, taintSpec := range taintSpecs {\n\t\ttaint, err := parseTaint(taintSpec)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttaints = append(taints, taint)\n\t}\n\n\treturn taints, nil\n}\n","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L1099-L1135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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').","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."],"exampleFix":"// before\nspotinst/ocean/max-size: \"1,000\"\n// after\nspotinst/ocean/max-size: \"1000\"","handlingStrategy":"validation","validationCode":"func validInt(s string) bool {\n\t_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)\n\treturn err == nil\n}\nif !validInt(cfg.MaxSize) { return fmt.Errorf(\"expected plain base-10 integer, got %q\", cfg.MaxSize) }","typeGuard":null,"tryCatchPattern":"if n, err := parseInt(raw); err != nil {\n\treturn fmt.Errorf(\"integer field %q: %w\", key, err)\n}","preventionTips":["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`."],"tags":["config","parsing","integer","spotinst"],"backgroundTag":"invalid-number-config-value","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}