{"record":{"id":"2f73ed9c86d51bf2","repo":"weaviate/weaviate","slug":"creating-nested-object-array","errorCode":null,"errorMessage":"creating nested object array","messagePattern":"creating nested object array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/handlers/grpc/v1/mapping.go","lineNumber":125,"sourceCode":"\t\treturn m.NewNilValue(), nil\n\t}\n\tswitch dt {\n\tcase schema.DataTypeObject:\n\t\tif _, ok := v.(map[string]interface{}); !ok {\n\t\t\treturn nil, protoimpl.X.NewError(\"invalid type: %T expected map[string]interface{}\", v)\n\t\t}\n\t\tobj, err := m.newObject(v.(map[string]interface{}), parent, prop)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"creating nested object\")\n\t\t}\n\t\treturn NewObjectValue(obj), nil\n\tcase schema.DataTypeObjectArray:\n\t\tif _, ok := v.([]interface{}); !ok {\n\t\t\treturn nil, protoimpl.X.NewError(\"invalid type: %T expected []map[string]interface{}\", v)\n\t\t}\n\t\tlist, err := m.newObjectList125(v.([]interface{}), parent, prop)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"creating nested object array\")\n\t\t}\n\t\treturn newListValue(list), nil\n\tdefault:\n\t\treturn nil, protoimpl.X.NewError(\"invalid type: %T\", v)\n\t}\n}\n\n// NewObject constructs a Object from a general-purpose Go map.\n// The map keys must be valid UTF-8.\n// The map values are converted using NewValue.\nfunc (m *Mapper) newObject(v map[string]interface{}, parent schema.PropertyInterface, selectProp search.SelectProperty) (*pb.Properties, error) {\n\tif !selectProp.IsObject {\n\t\treturn nil, errors.New(\"select property is not an object\")\n\t}\n\tx := &pb.Properties{Fields: make(map[string]*pb.Value, len(v))}\n\tfor _, selectProp := range selectProp.Props {\n\t\tval, ok := v[selectProp.Name]\n\t\tif !ok {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/handlers/grpc/v1/mapping.go#L107-L143","documentation":"NewNestedValue handles DataTypeObjectArray by converting each element via newObjectList125. If any element fails conversion (e.g. an element of the array is not a valid nested object per the schema), the failure is wrapped as \"creating nested object array\".","triggerScenarios":"Client sends an object-array property where at least one array element contains a field of the wrong type or an invalid nested structure relative to the schema.","commonSituations":"Batch imports with mixed-shape arrays, clients sending nested arrays where the schema expects an array of objects (no deeper nesting), SDK serialization bugs.","solutions":["Ensure every array element is an object whose fields match the nested schema","Flatten invalid deeper nesting (arrays of arrays are not supported)","Validate one element offline against the schema before batch sending","Update client SDK to a version matching the server's schema handling"],"exampleFix":"// before: element is not an object\n{\"tags\": [\"a\", \"b\"]} // schema declares tags as DataTypeObjectArray\n// after: each element must be an object\n{\"tags\": [{\"name\": \"a\"}, {\"name\": \"b\"}]}","handlingStrategy":"validation","validationCode":"// every element must be a valid object per schema\narr, ok := value.([]interface{})\nif !ok { return errors.New(\"expected object array\") }\nfor i, el := range arr {\n    if _, ok := el.(map[string]interface{}); !ok {\n        return fmt.Errorf(\"element %d is not an object\", i)\n    }\n}","typeGuard":"func isObjectArray(v interface{}) bool {\n    arr, ok := v.([]interface{})\n    if !ok { return false }\n    for _, el := range arr {\n        if _, ok := el.(map[string]interface{}); !ok { return false }\n    }\n    return true\n}","tryCatchPattern":"list, err := mapper.NewNestedValue(val, dt, nested, selectProp)\nif err != nil {\n    return nil, fmt.Errorf(\"array property %q: %w\", selectProp.Name, err)\n}","preventionTips":["Never nest arrays directly inside object arrays","Validate each array element's shape against the nested schema","Keep batch payloads homogeneous in element structure"],"tags":["grpc","nested-object-array","schema-validation"],"backgroundTag":"nested-object-type-mismatch","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}