{"record":{"id":"b75e04d903e7c43f","repo":"kubernetes/kops","slug":"unexpected-boolean-value-q","errorCode":null,"errorMessage":"unexpected boolean value: %q","messagePattern":"unexpected boolean value: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":1101,"sourceCode":"\t}\n\n\treturn opts, nil\n}\n\nfunc (b *SpotInstanceGroupModelBuilder) buildInstanceMetadataOptions(ig *kops.InstanceGroup) *spotinsttasks.InstanceMetadataOptions {\n\tif ig.Spec.InstanceMetadata != nil {\n\t\topt := new(spotinsttasks.InstanceMetadataOptions)\n\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","sourceCodeStart":1083,"sourceCodeEnd":1119,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L1083-L1119","documentation":"parseBool wraps strconv.ParseBool failures when converting a cluster/spec string field (e.g. from the Spotinst config) into a *bool. It fires whenever a value that must be a boolean literal (1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False) is anything else. The message includes the offending string in %q so the bad value is visible.","triggerScenarios":"Any buildElastigroup/buildOcean/buildLaunchSpec/buildAutoScalerOpts call reading a string config key parsed via parseBool where the value is not a valid Go boolean literal — e.g. 'yes', 'on', 'enabled', '1 ' with trailing space, or an empty string from a missing/blank field.","commonSituations":"Users set spotinst options like 'spotinst/hydrated: yes' or 'true' with whitespace/quotes in the cluster spec; YAML tools writing 'True' variants are fine, but 'yes'/'on' (valid YAML booleans) are not valid for strconv.ParseBool.","solutions":["Locate the quoted value in the error message and change it to one of strconv.ParseBool's accepted literals: true/false (or 1/0, t/f, T/F, TRUE/FALSE).","Strip whitespace and quotes from the config value before it reaches kOps (edit the cluster spec / userdata source).","If the key should be absent when unset, delete the empty value rather than leaving ''.","If you control the code, consider accepting YAML-style booleans via a more lenient parser before calling parseBool."],"exampleFix":"// before (cluster spec / config value)\nspotinst/ocean/autoscaler/down: \"yes\"\n// after\nspotinst/ocean/autoscaler/down: \"true\"","handlingStrategy":"validation","validationCode":"func validBool(s string) bool {\n\ts = strings.TrimSpace(s)\n\tif s == \"\" { return false }\n\t_, err := strconv.ParseBool(s)\n\treturn err == nil\n}\n// call before applying the spec:\nif !validBool(cfg.Down) { return fmt.Errorf(\"config field must be a Go boolean literal (true/false/1/0/t/f), got %q\", cfg.Down) }","typeGuard":null,"tryCatchPattern":"if v, err := parseBool(raw); err != nil {\n\treturn fmt.Errorf(\"field %q: %w\", key, err) // inspect %q value in message\n}","preventionTips":["Use only true/false (or 1/0) in cluster spec boolean fields — never yes/no/on/off.","Trim whitespace and shell quotes from config values before applying a cluster.","kops replace / kops edit and re-read the spec with `kops get -oyaml` to verify values.","Lint cluster specs in CI with a schema check before `kops update`."],"tags":["config","parsing","boolean","spotinst"],"backgroundTag":"invalid-boolean-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"}