weaviate/weaviate · error
element %d: expected boolean element to be bool, but got %T
Error message
element %d: expected boolean element to be bool, but got %T
What it means
mergeBooleanProps reduces grouped boolean values during groupBy (majority vote: returns true if countTrue >= countFalse pattern of counting). Every element must be a Go bool; anything else aborts with the index and actual type.
Source
Thrown at usecases/traverser/grouper/merge_group.go:227
for i, elem := range in {
asFloat, ok := elem.(float64)
if !ok {
return 0, fmt.Errorf("element %d: expected numerical element to be float64, but got %T", i, elem)
}
sum += asFloat
}
return sum / float64(len(in)), nil
}
func mergeBooleanProps(in []interface{}) (bool, error) {
var countTrue uint
var countFalse uint
for i, elem := range in {
asBool, ok := elem.(bool)
if !ok {
return false, fmt.Errorf("element %d: expected boolean element to be bool, but got %T", i, elem)
}
if asBool {
countTrue++
} else {
countFalse++
}
}
return countTrue >= countFalse, nil
}
func mergeGeoProps(in []interface{}) (*models.GeoCoordinates, error) {
var sumLat float32
var sumLon float32
for i, elem := range in {
asGeo, ok := elem.(*models.GeoCoordinates)View on GitHub (pinned to 75aa4b6d11)
Solutions
- Verify the property dataType is boolean and values were imported as real JSON booleans
- Fix clients writing "true" strings or 1/0 into boolean properties
- Re-import or update offending objects with proper boolean values
- Check the error's element index and property name (from the wrapping 'prop' error) to locate the bad data
Example fix
// before (bad import)
{"hasStock": "true"}
// after
{"hasStock": true} Defensive patterns
Strategy: validation
Validate before calling
// Validate booleans before import
for (const obj of objects) {
if (obj.inStock !== undefined && typeof obj.inStock !== 'boolean') {
throw new Error('inStock must be a real boolean, got ' + typeof obj.inStock)
}
} Prevention
- Send true/false, not "true"/"false" or 1/0, for boolean properties
- Add client-side schema validation before batch imports
- Re-check legacy data written by old clients with string booleans
- Use the error's element index to locate the corrupt object when debugging
When it happens
Trigger: A groupBy query over a boolean property where an extracted element is not bool — e.g. the value was written as the string "true"/"false" or 0/1 and decoded as string/number.
Common situations: Clients sending booleans as strings or numbers on import, causing stored/extracted values to deserialize into non-bool types during grouped merging.
Related errors
- boolean: %w
- element %d: expected textual element to be string, but got %
- element %d: expected numerical element to be float64, but go
- element %d: expected geo element to be *models.GeoCoordinate
- element %d: expected reference values to be slice, but got %
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/57c506ec635ce536.
Report an issue: GitHub.