weaviate/weaviate · error

property %q has unexpected data type %q

Error message

property %q has unexpected data type %q

What it means

This is a defensive default branch in AssignPositions' data-type switch. schema.AsNested only returns DataTypeObject or DataTypeObjectArray, so any other value reaching the default branch would indicate a corrupted/inconsistent DataType. The error exists to fail loudly instead of silently skipping the property.

Source

Thrown at adapters/repos/db/inverted/nested/assign.go:90

	dt, ok := schema.AsNested(prop.DataType)
	if !ok {
		return nil, fmt.Errorf("property %q is not a nested type", prop.Name)
	}

	var elements []any
	switch dt {
	case schema.DataTypeObject:
		elements = []any{value}
	case schema.DataTypeObjectArray:
		arr, ok := value.([]any)
		if !ok {
			return nil, fmt.Errorf("expected []any for object[] %q, got %T", prop.Name, value)
		}
		elements = arr
	default:
		// Unreachable: dt is returned by AsNested which only returns members of
		// NestedDataTypes (DataTypeObject, DataTypeObjectArray).
		return nil, fmt.Errorf("property %q has unexpected data type %q", prop.Name, dt)
	}

	if len(elements) == 0 {
		return &AssignResult{}, nil
	}

	result := &AssignResult{}
	var allPositions []uint64

	for i, elem := range elements {
		if i+1 >= MaxRoots {
			return nil, fmt.Errorf("element count %d exceeds maximum %d for property %q",
				i+1, MaxRoots-1, prop.Name)
		}
		rootIdx := uint16(i + 1)

		elemMap, ok := elem.(map[string]any)
		if !ok {

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. No user action needed if unmodified — treat any occurrence as a bug and report it with the property definition.
  2. If you maintain a fork, update the switch in assign.go to handle the new AsNested return value.
  3. Verify the property's DataType against the schema to rule out corruption.
Defensive patterns

Strategy: type-guard

Validate before calling

switch {
case schema.IsNestedObject(prop.DataType): // ok
case schema.IsNestedObjectArray(prop.DataType): // ok
default: // not a nested property; do not call AssignPositions
}

Try / catch

res, err := nested.AssignPositions(prop, value)
if err != nil && strings.Contains(err.Error(), "unexpected data type") {
    // report as a bug: AsNested contract violated
}

Prevention

When it happens

Trigger: Effectively unreachable in normal operation; would fire only if schema.AsNested's contract changed to return additional nested data types without the switch being updated, or if DataType is corrupted in memory.

Common situations: After upgrading Weaviate where schema internals changed; custom forks extending AsNested with new types; debugging unexpected schema state.

Related errors


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