{"record":{"id":"7529775224719223","repo":"kubernetes/kops","slug":"cannot-interpret-q-value-as-bool","errorCode":null,"errorMessage":"cannot interpret %q value as bool","messagePattern":"cannot interpret %q value as bool","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/reflectutils/access.go","lineNumber":196,"sourceCode":"\t\t\tv.SetMapIndex(reflect.ValueOf(name), valueArray)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unhandled type %q\", t)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tvar newV reflect.Value\n\n\tswitch t {\n\tcase \"string\":\n\t\tnewV = reflect.ValueOf(newValue)\n\n\tcase \"bool\":\n\t\tb, err := strconv.ParseBool(newValue)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot interpret %q value as bool\", newValue)\n\t\t}\n\t\tnewV = reflect.ValueOf(b)\n\n\tcase \"int64\", \"int32\", \"int16\", \"int\":\n\t\tswitch t {\n\t\tcase \"int\":\n\t\t\tv, err := strconv.Atoi(newValue)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot interpret %q value as integer\", newValue)\n\t\t\t}\n\t\t\tnewV = reflect.ValueOf(v)\n\t\tcase \"int16\":\n\t\t\tv, err := strconv.ParseInt(newValue, 10, 16)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot interpret %q value as int16\", newValue)\n\t\t\t}\n\t\t\tv16 := int16(v)\n\t\t\tnewV = reflect.ValueOf(v16)","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/reflectutils/access.go#L178-L214","documentation":"The target field is a bool; setType uses strconv.ParseBool on the string value and this error is returned when the string is not one of 1,t,T,TRUE,true,True,0,f,F,FALSE,false,False. The offending string is quoted in the message.","triggerScenarios":"SetString(&obj, \"spec.someBool\", \"yes\") or \"enabled\" or \"1.0\" — any value ParseBool rejects.","commonSituations":"Shell one-liners using `kops set cluster spec.X.enabled=yes`; YAML-style true/false variants like \"on\"/\"off\" that Go doesn't accept.","solutions":["Use a ParseBool-accepted literal: true/false, 1/0, t/f, TRUE/FALSE, True/False.","Change \"yes\"/\"no\"/\"on\"/\"off\" to true/false before calling.","Pre-validate with strconv.ParseBool and report a friendly message to the user."],"exampleFix":"// before\nSetString(&ig, \"spec.machineType\", ...) // e.g. \"yes\" on a bool field\nSetString(&ig, \"spec.spot\", \"yes\")\n// after\nSetString(&ig, \"spec.spot\", \"true\")","handlingStrategy":"validation","validationCode":"if _, err := strconv.ParseBool(val); err != nil {\n    return fmt.Errorf(\"value %q is not a valid Go bool (use true/false/1/0)\", val)\n}","typeGuard":"func isGoBool(s string) bool {\n    _, err := strconv.ParseBool(s)\n    return err == nil\n}","tryCatchPattern":"if err := SetString(&obj, path, val); err != nil {\n    if strings.Contains(err.Error(), \"as bool\") {\n        return fmt.Errorf(\"%q is not a bool; use true or false\", val)\n    }\n    return err\n}","preventionTips":["Normalize yes/no/on/off to true/false in CLI wrappers.","Remember Go accepts only 1/0/t/f/true/false and mixed-case variants.","Trim whitespace from user input before setting."],"tags":["go","parsing","bool"],"backgroundTag":"invalid-bool-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"}