weaviate/weaviate · error

element [%d]: %w

Error message

element [%d]: %w

What it means

Weaviate's auto-schema analyzes an incoming array-typed property value by determining the type of each element independently via determineArrayType. When any single element fails type determination, the error is wrapped with its index so the developer knows exactly which array element was the problem. It is thrown during object creation/update when auto-schema is enabled and a new or untyped property contains an array with an invalid element.

Source

Thrown at usecases/objects/auto_schema.go:299

			}
			if dt, ok := m.asPhoneNumber(typedValue); ok {
				return dt, nil
			}
		}
		return []schema.DataType{schema.DataTypeObject}, nil
	case []interface{}:
		if len(typedValue) == 0 {
			return fallbackArrayDataType, nil
		}

		refDataTypes := []schema.DataType{}
		var isRef bool
		var determinedDataType schema.DataType

		for i := range typedValue {
			dataType, refDataType, err := m.determineArrayType(typedValue[i], ofNestedProp)
			if err != nil {
				return nil, fmt.Errorf("element [%d]: %w", i, err)
			}
			if i == 0 {
				isRef = refDataType != ""
				determinedDataType = dataType
			}
			if dataType != "" {
				// if an array contains text and UUID/Date, the type should be text
				if determinedDataType == schema.DataTypeTextArray && (dataType == schema.DataTypeUUIDArray || dataType == schema.DataTypeDateArray) {
					continue
				}
				if determinedDataType == schema.DataTypeDateArray && (dataType == schema.DataTypeUUIDArray || dataType == schema.DataTypeTextArray) {
					determinedDataType = schema.DataTypeTextArray
					continue
				}
				if determinedDataType == schema.DataTypeUUIDArray && (dataType == schema.DataTypeDateArray || dataType == schema.DataTypeTextArray) {
					determinedDataType = schema.DataTypeTextArray
					continue
				}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Inspect the array element at the reported index and correct it to a supported scalar type (text, int, number, boolean, date, uuid, or a nested object map).
  2. Pre-validate property values client-side before posting so all array elements are homogeneous and of a known JSON type.
  3. If the property should be a specific type, define it explicitly in the collection schema instead of relying on auto-schema inference.
  4. Check the client/serialization layer for bugs that introduce nulls or nested arrays into the payload.

Example fix

// before (invalid nested array element)
{"properties": {"tags": [["a"], "b"]}}
// after
{"properties": {"tags": ["a", "b"]}}
Defensive patterns

Strategy: validation

Validate before calling

func validArrayElement(v interface{}) bool {
	switch v.(type) {
	case string, int, int64, float64, bool, nil:
		return v != nil
	case map[string]interface{}:
		return true
	case []interface{}:
		return false // nested arrays unsupported
	default:
		return false
	}
}
for i, el := range arr {
	if !validArrayElement(el) { return fmt.Errorf("element %d invalid", i) }
}

Type guard

func isSupportedScalar(v interface{}) bool {
	switch v.(type) {
	case string, float64, bool:
		return true
	default:
		return false
	}
}

Prevention

When it happens

Trigger: POST /v1/objects (or batch objects) with auto-schema enabled, supplying a property whose value is an array where at least one element is not a recognized primitive (e.g. a nested array, a nil entry of unsupported type, or a map that matches no known object type). The failing index is reported in the message.

Common situations: Sending heterogeneous or malformed JSON arrays (e.g. [[1,2],[3,4]]), passing nulls inside arrays, or a client serializing values incorrectly (numbers as strings mixed with numbers). Also common when an embedding pipeline emits unexpected element types for text2vec inputs.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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