weaviate/weaviate · error

element : 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.

Solutions

  1. Verify the property dataType is boolean and values were imported as real JSON booleans
  2. Fix clients writing "true" strings or 1/0 into boolean properties
  3. Re-import or update offending objects with proper boolean values
  4. 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

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


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/57c506ec635ce536. Report an issue: GitHub.

Appendix: 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)