{"record":{"id":"76fc2f8caf9126dd","repo":"nats-io/nats-server","slug":"expected-boolean-value-but-got-s","errorCode":null,"errorMessage":"expected boolean value, but got '%s'","messagePattern":"expected boolean value, but got '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conf/parse.go","lineNumber":366,"sourceCode":"\t\t}\n\tcase itemFloat:\n\t\tnum, err := strconv.ParseFloat(it.val, 64)\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*strconv.NumError); ok &&\n\t\t\t\te.Err == strconv.ErrRange {\n\t\t\t\treturn fmt.Errorf(\"float '%s' is out of the range\", it.val)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"expected float, but got '%s'\", it.val)\n\t\t}\n\t\tsetValue(it, num)\n\tcase itemBool:\n\t\tswitch strings.ToLower(it.val) {\n\t\tcase \"true\", \"yes\", \"on\":\n\t\t\tsetValue(it, true)\n\t\tcase \"false\", \"no\", \"off\":\n\t\t\tsetValue(it, false)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"expected boolean value, but got '%s'\", it.val)\n\t\t}\n\n\tcase itemDatetime:\n\t\tdt, err := time.Parse(\"2006-01-02T15:04:05Z\", it.val)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"expected Zulu formatted DateTime, but got '%s'\", it.val)\n\t\t}\n\t\tsetValue(it, dt)\n\tcase itemArrayStart:\n\t\tvar array = make([]any, 0)\n\t\tp.pushContext(array)\n\tcase itemArrayEnd:\n\t\tarray := p.ctx\n\t\tp.popContext()\n\t\tsetValue(it, array)\n\tcase itemVariable:\n\t\tvalue, found, err := p.lookupVariable(it.val)","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/conf/parse.go#L348-L384","documentation":"An item classified as boolean was compared (case-insensitively via strings.ToLower) against the accepted sets true/yes/on and false/no/off, and matched none. The parser only accepts these literal spellings for booleans.","triggerScenarios":"processItem (from parse) hits case itemBool with it.val such as 'TRUE ' with stray whitespace it doesn't trim differently, 'enabled', '1', '0', 't', 'ja', or an empty value.","commonSituations":"Users writing numeric booleans (1/0), YAML-style 'True' is fine but 'enabled'/'disabled' is not, localized words, or quotes/whitespace around the value.","solutions":["Change the value to one of: true, yes, on, false, no, off (case-insensitive).","Replace 1/0 with true/false.","Replace semantic words like enabled/disabled with yes/no.","Strip surrounding whitespace or quotes from the value in the config file."],"exampleFix":"// before\nfeature_enabled = 1\n// after\nfeature_enabled = true","handlingStrategy":"validation","validationCode":"var boolWords = map[string]bool{\"true\": true, \"yes\": true, \"on\": true, \"false\": true, \"no\": true, \"off\": true}\nif !boolWords[strings.ToLower(raw)] {\n\treturn fmt.Errorf(\"%q is not an accepted boolean\", raw)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to true/false in configs (the safest accepted pair).","Never use 1/0 or enabled/disabled for booleans.","Trim whitespace when authoring config values."],"tags":["config","parsing","boolean"],"backgroundTag":"invalid-boolean-value","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}