{"record":{"id":"e739d0cf30e2e7d9","repo":"kubernetes/kops","slug":"unexpected-float-value-q","errorCode":null,"errorMessage":"unexpected float value: %q","messagePattern":"unexpected float value: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":1109,"sourceCode":"\t\topt.HTTPPutResponseHopLimit = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit))\n\t\topt.HTTPTokens = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens))\n\t\treturn opt\n\t}\n\treturn nil\n}\n\nfunc parseBool(str string) (*bool, error) {\n\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 {","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L1091-L1127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the quoted value in the error to a plain decimal number, e.g. '50%' -> '50', '0,9' -> '0.9'.","Use '.' as the decimal separator, never ','.","Remove surrounding whitespace/quotes from the value.","If the field is optional, remove the key entirely instead of leaving an empty string."],"exampleFix":"// before\nspotinst/ocean/autoscaler/scale-down-utilization-threshold: \"50%\"\n// after\nspotinst/ocean/autoscaler/scale-down-utilization-threshold: \"0.5\"","handlingStrategy":"validation","validationCode":"func validFloat(s string) bool {\n\t_, err := strconv.ParseFloat(strings.TrimSpace(s), 64)\n\treturn err == nil\n}\nif !validFloat(cfg.Threshold) { return fmt.Errorf(\"expected decimal number with '.' separator, got %q\", cfg.Threshold) }","typeGuard":null,"tryCatchPattern":"if f, err := parseFloat(raw); err != nil {\n\treturn fmt.Errorf(\"numeric field %q: %w\", key, err)\n}","preventionTips":["Write ratios as plain decimals ('0.5'), never '50%'.","Always use '.' as decimal separator regardless of locale.","Omit optional numeric keys entirely instead of leaving empty strings.","Run `kops get cluster -oyaml` and grep numeric fields before `kops update`."],"tags":["config","parsing","float","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-12T12:17:11.808Z"}