nats-io/nats-server · error
expected boolean value, but got '%s'
Error message
expected boolean value, but got '%s'
What it means
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.
Source
Thrown at conf/parse.go:366
}
case itemFloat:
num, err := strconv.ParseFloat(it.val, 64)
if err != nil {
if e, ok := err.(*strconv.NumError); ok &&
e.Err == strconv.ErrRange {
return fmt.Errorf("float '%s' is out of the range", it.val)
}
return fmt.Errorf("expected float, but got '%s'", it.val)
}
setValue(it, num)
case itemBool:
switch strings.ToLower(it.val) {
case "true", "yes", "on":
setValue(it, true)
case "false", "no", "off":
setValue(it, false)
default:
return fmt.Errorf("expected boolean value, but got '%s'", it.val)
}
case itemDatetime:
dt, err := time.Parse("2006-01-02T15:04:05Z", it.val)
if err != nil {
return fmt.Errorf(
"expected Zulu formatted DateTime, but got '%s'", it.val)
}
setValue(it, dt)
case itemArrayStart:
var array = make([]any, 0)
p.pushContext(array)
case itemArrayEnd:
array := p.ctx
p.popContext()
setValue(it, array)
case itemVariable:
value, found, err := p.lookupVariable(it.val)View on GitHub (pinned to 3a66a489d2)
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.
Example fix
// before feature_enabled = 1 // after feature_enabled = true
Defensive patterns
Strategy: validation
Validate before calling
var boolWords = map[string]bool{"true": true, "yes": true, "on": true, "false": true, "no": true, "off": true}
if !boolWords[strings.ToLower(raw)] {
return fmt.Errorf("%q is not an accepted boolean", raw)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Users writing numeric booleans (1/0), YAML-style 'True' is fine but 'enabled'/'disabled' is not, localized words, or quotes/whitespace around the value.
Related errors
- float '%s' is out of the range
- expected float, but got '%s'
- expected Zulu formatted DateTime, but got '%s'
- variable reference for '%s' on line %d could not be parsed:
- error parsing include file '%s', %v
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/76fc2f8caf9126dd.
Report an issue: GitHub.