{"record":{"id":"be85796dd7c55651","repo":"weaviate/weaviate","slug":"expected-previous-schema-to-be-map-but-got-v","errorCode":null,"errorMessage":"expected previous schema to be map, but got %#v","messagePattern":"expected previous schema to be map, but got %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/objects/merge.go","lineNumber":238,"sourceCode":"\t\treturn fmt.Errorf(\"empty uuid\")\n\t}\n\treturn nil\n}\n\nfunc (m *Manager) mergeObjectSchemaAndVectorize(ctx context.Context, prevPropsSch models.PropertySchema,\n\tnextProps map[string]interface{}, prevVec, nextVec []float32, prevVecs models.Vectors, nextVecs models.Vectors,\n\tid strfmt.UUID, class *models.Class,\n) (*models.Object, error) {\n\tvar mergedProps map[string]interface{}\n\n\tvector := nextVec\n\tvectors := nextVecs\n\tif prevPropsSch == nil {\n\t\tmergedProps = nextProps\n\t} else {\n\t\tprevProps, ok := prevPropsSch.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"expected previous schema to be map, but got %#v\", prevPropsSch)\n\t\t}\n\n\t\tmergedProps = map[string]interface{}{}\n\t\tfor propName, propValue := range prevProps {\n\t\t\tmergedProps[propName] = propValue\n\t\t}\n\t\tfor propName, propValue := range nextProps {\n\t\t\tmergedProps[propName] = propValue\n\t\t}\n\t}\n\n\t// Note: vector could be a nil vector in case a vectorizer is configured,\n\t// then the vectorizer will set it\n\tobj := &models.Object{Class: class.Class, Properties: mergedProps, Vector: vector, Vectors: vectors, ID: id}\n\tif err := m.modulesProvider.UpdateVector(ctx, obj, class, m.findObject, m.logger); err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/objects/merge.go#L220-L256","documentation":"mergeObjectSchemaAndVectorize type-asserts the previous object's PropertySchema to map[string]interface{} before merging new properties. If the stored property schema came back as a different concrete type (e.g. a non-map PropertySchema variant), the assertion fails and this error is returned. It indicates internal state that violates the merge code's expectation rather than a user-input problem.","triggerScenarios":"patchObject merges an object whose previous properties, when read from the repo, deserialize into something other than map[string]interface{} — typically corrupt or unexpectedly shaped stored properties, or a custom repo/migration returning an alternate PropertySchema implementation.","commonSituations":"After restoring a backup produced by a different Weaviate version; custom adapters or tests injecting a PropertySchema type like []interface{} or a struct; a schema-migration bug where properties were serialized with a non-map encoder.","solutions":["Inspect the affected object's stored properties (GET the object) to see if properties are malformed","Re-write the object with a full PUT (replace) so its property schema is re-encoded as a standard map","Check whether the object came from a backup or migration from an incompatible version; re-export/re-import with the current version","If reproducible on stock data, file a bug with the object/schema shapes — this should be unreachable for normal writes"],"exampleFix":"// before (test/injected prevPropsSch of wrong type)\nprev := []interface{}{\"not-a-map\"}\n\n// after\nprev := map[string]interface{}{\"name\": \"existing\"}","handlingStrategy":"fallback","validationCode":"// caller-side sanity check on a fetched object\nif _, ok := obj.Properties.(map[string]interface{}); !ok && obj.Properties != nil {\n    return errors.New(\"stored properties are not a map; object may be corrupt\")\n}","typeGuard":"func propsAreMap(p models.PropertySchema) bool {\n    _, ok := p.(map[string]interface{})\n    return ok\n}","tryCatchPattern":"if err != nil {\n    var e *objects.Error\n    if errors.As(err, &e) && strings.Contains(e.Error(), \"expected previous schema to be map\") {\n        // fall back to full PUT replace of the object\n    }\n}","preventionTips":["Avoid custom repo adapters returning alternate PropertySchema types","Re-import objects restored from foreign-version backups","Treat this error as data corruption: inspect and rewrite the object"],"tags":["go","type-assertion","internal-state","merge"],"backgroundTag":"unexpected-type","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"}