t8y2/dbx · error
invalid %s: expected boolean
Error message
invalid %s: expected boolean
What it means
hoconBool throws this when the value at the config path exists but is neither a hocon.Boolean nor a hocon.String — i.e. it is some other HOCON type such as a number, object, or array. The driver only coerces booleans and boolean-like strings.
Source
Thrown at agents/drivers/cassandra-go/config_file.go:435
return value, true, nil
}
func hoconBool(config *hocon.Config, path string) (bool, bool, error) {
value := config.Get(path)
if value == nil {
return false, false, nil
}
switch typed := value.(type) {
case hocon.Boolean:
return bool(typed), true, nil
case hocon.String:
parsed, err := strconv.ParseBool(string(typed))
if err != nil {
return false, false, fmt.Errorf("invalid %s: %w", path, err)
}
return parsed, true, nil
default:
return false, false, fmt.Errorf("invalid %s: expected boolean", path)
}
}
func firstHOCONBool(config *hocon.Config, paths ...string) (bool, bool, error) {
for _, path := range paths {
value, ok, err := hoconBool(config, path)
if err != nil || ok {
return value, ok, err
}
}
return false, false, nil
}
func hoconProtocolVersion(config *hocon.Config, path string) (int, bool, error) {
value := config.Get(path)
if value == nil {
return 0, false, nil
}View on GitHub (pinned to c0390bff16)
Solutions
- Inspect the value at the reported path and replace it with a boolean literal `true`/`false`.
- If an object was accidentally nested there, fix the indentation/bracing so the key points at a scalar.
- Replace numeric truthy values (`1`) with explicit booleans.
Example fix
// before
reconnect = {
enabled = true
}
// after
reconnect = true Defensive patterns
Strategy: validation
Validate before calling
func ensureScalarBoolPath(cfg *hocon.Config, path string) error {
v := cfg.Get(path)
if v == nil {
return nil
}
switch v.(type) {
case hocon.Boolean, hocon.String:
return nil
default:
return fmt.Errorf("%s resolves to a non-scalar (%T); it must point at a boolean", path, v)
}
} Type guard
func isBoolOrBoolString(v interface{}) bool {
switch t := v.(type) {
case hocon.Boolean:
return true
case hocon.String:
_, err := strconv.ParseBool(string(t))
return err == nil
default:
return false
}
} Try / catch
if _, ok, err := hoconBool(cfg, path); err != nil {
return fmt.Errorf("%s must be a boolean scalar; check for accidental nesting: %w", path, err)
} Prevention
- Check HOCON brace placement so boolean keys are not accidentally nested objects.
- Avoid HOCON object merges that replace a scalar with a block.
- Keep one key per scalar; do not merge multiple config fragments blindly.
When it happens
Trigger: applyJavaDriverHOCON, applyHOCONSSL, applyNativeHOCON, or firstHOCONBool encountering a boolean key whose value is a number (e.g. `2`), a nested object, or an array.
Common situations: Accidentally nesting config keys so a boolean path resolves to an object, or setting a numeric flag expecting truthiness semantics.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- invalid %s: expected V3, V4, or V5
- invalid %s: %w
- Agent runtime thread limits must be positive
- H2 JDBC driver rejected URL: " + buildJdbcUrl(params)
- Custom H2 driver profile requires at least one JDBC JAR path
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/78b7444e4f480593.
Report an issue: GitHub.