zincsearch/zincsearch · error
GetBoolFromMap: value [%s] shuld be a bool
Error message
GetBoolFromMap: value [%s] shuld be a bool
What it means
GetBoolFromMap found the requested key but its value is not a bool. The message (which contains a typo: "shuld") prints the key name so you can locate the offending field. JSON configs frequently carry booleans as strings ("true") which will fail this assertion. Fix the value's type in the settings map.
Source
Thrown at pkg/zutils/map.go:40
if err != nil {
return "", fmt.Errorf("GetStringFromMap: key [%s] not found", key)
}
vs, ok := v.(string)
if !ok {
return "", fmt.Errorf("GetStringFromMap: value [%s] should be a string", key)
}
return vs, nil
}
func GetBoolFromMap(m interface{}, key string) (bool, error) {
v, err := GetAnyFromMap(m, key)
if err != nil {
return false, fmt.Errorf("GetBoolFromMap: key [%s] not found", key)
}
vs, ok := v.(bool)
if !ok {
return false, fmt.Errorf("GetBoolFromMap: value [%s] shuld be a bool", key)
}
return vs, nil
}
func GetFloatFromMap(m interface{}, key string) (float64, error) {
v, err := GetAnyFromMap(m, key)
if err != nil {
return 0, fmt.Errorf("GetFloatFromMap: key [%s] not found", key)
}
vs, ok := v.(float64)
if !ok {
return 0, fmt.Errorf("GetFloatFromMap: value [%s] should be a float64", key)
}
return vs, nil
}
View on GitHub (pinned to dd2f8afd65)
Solutions
- Change the key's value to a real boolean (unquoted true/false) in the settings map.
- If the value is the string "true"/"false", convert it with strconv.ParseBool before building the map.
- If you control the code path, accept both and normalize with a tolerant helper.
Example fix
// before
{"type": "dict", "suppress": "true"}
// after
{"type": "dict", "suppress": true} Defensive patterns
Strategy: type-guard
Validate before calling
func normalizeBool(m map[string]interface{}, key string) {
if s, ok := m[key].(string); ok {
if b, err := strconv.ParseBool(s); err == nil {
m[key] = b
}
}
} Type guard
func isBool(v interface{}) bool { _, ok := v.(bool); return ok } Try / catch
v, err := zutils.GetBoolFromMap(settings, "suppress")
if err != nil {
if strings.Contains(err.Error(), "shuld be a bool") {
return fmt.Errorf("field 'suppress' must be unquoted true/false, got %T", settings["suppress"])
}
return err
} Prevention
- Never quote booleans in JSON configs ("true" is a string, true is a bool).
- Run configs through json.Unmarshal and type-check fields before use.
- Normalize stringly-typed booleans with strconv.ParseBool in a preprocessing pass.
- Add a schema validator (e.g. JSON Schema with type:boolean) to your config pipeline.
When it happens
Trigger: Calling GetBoolFromMap via NewRegexpAnalyzer, NewDictTokenFilter, or an anonymous parse func where the key exists but holds e.g. the string "true", an int 1, or null instead of a JSON boolean.
Common situations: Hand-written configs quoting booleans ("case_sensitive": "true"); configs generated from form inputs that yield strings; YAML/JSON round-trips that turned bools into strings.
Related errors
- GetStringFromMap: value [%s] should be a string
- GetFloatFromMap: value [%s] should be a float64
- GetStringSliceFromMap: value [%s] should be an array of stri
- GetMapFromMap: value [%s] should be an object
- ErrorTypeParsingException
AI-assisted analysis of zincsearch/zincsearch@dd2f8afd65 (2026-09-03).
Data as JSON: /api/errors/a55c5c1eccd6b2c6.
Report an issue: GitHub.