{"record":{"id":"748614fd20ce28c6","repo":"weaviate/weaviate","slug":"cannot-add-property-to-a-non-existing-index-for-s","errorCode":null,"errorMessage":"cannot add property to a non-existing index for %s","messagePattern":"cannot add property to a non-existing index for (.+?)","errorType":"http","errorClass":null,"httpStatus":422,"severity":"error","filePath":"adapters/repos/db/migrator.go","lineNumber":572,"sourceCode":"// shardHasProperty reports whether prop's value index exists on this shard. Geo\n// props get a property-specific index and no filterable bucket, so probing that\n// bucket would report them missing forever.\nfunc shardHasProperty(shard ShardLike, prop *models.Property) bool {\n\tif dt, _ := schema.AsPrimitive(prop.DataType); dt == schema.DataTypeGeoCoordinates {\n\t\treturn shard.hasGeoIndexForProp(prop.Name)\n\t}\n\treturn shard.Store().Bucket(helpers.BucketFromPropNameLSM(prop.Name)) != nil\n}\n\nfunc (m *Migrator) AddProperty(ctx context.Context, className string, prop ...*models.Property) error {\n\tindexID := indexID(schema.ClassName(className))\n\n\tm.classLocks.Lock(indexID)\n\tdefer m.classLocks.Unlock(indexID)\n\n\tidx := m.db.GetIndex(schema.ClassName(className))\n\tif idx == nil {\n\t\treturn errors.Errorf(\"cannot add property to a non-existing index for %s\", className)\n\t}\n\n\treturn idx.addProperty(ctx, prop...)\n}\n\nfunc (m *Migrator) UpdateProperty(ctx context.Context, className string, property *models.Property) error {\n\tindexID := indexID(schema.ClassName(className))\n\n\tm.classLocks.Lock(indexID)\n\tdefer m.classLocks.Unlock(indexID)\n\n\tidx := m.db.GetIndex(schema.ClassName(className))\n\tif idx == nil {\n\t\treturn errors.Errorf(\"cannot update property for a non-existing index for %s\", className)\n\t}\n\n\treturn idx.updateProperty(ctx, property)\n}","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/migrator.go#L554-L590","documentation":"Migrator.AddProperty looks up the Index for the given class in the DB before delegating to idx.addProperty. If no index exists for that class name (class never created, already dropped, or name mismatch), it returns this error instead of dereferencing a nil index. It indicates the schema operation raced with or followed an absent collection.","triggerScenarios":"Calling the schema API to add a property to a class whose index is absent from this node: class was deleted concurrently, the class name is misspelled/incorrectly cased, or the node hasn't finished replicating schema creation in a cluster.","commonSituations":"Race between DELETE /schema/... and PATCH add-property; multi-tenant setups where the operation targets a class removed on another node; client-side class-name typos (Weaviate class names are case-sensitive).","solutions":["Verify the class exists (GET /v1/schema/{className}) before adding the property; fix case-sensitive name mismatches.","Re-create the class (with the property included in the schema) if it was deleted; adding properties requires an existing index.","In a cluster, ensure schema replication has converged and the request hits a node with the class; retry after schema sync."],"exampleFix":"// before\nerr := client.Schema().PropertyCreator().\n    WithClassName(\"Article\"). // class deleted or wrong casing\n    WithProperty(prop).Do(ctx) // \"cannot add property to a non-existing index for Article\"\n// after\ncls, err := client.Schema().ClassGetter().WithClassName(\"Article\").Do(ctx)\nif err != nil || cls == nil {\n    return client.Schema().ClassCreator().WithClass(&models.Class{\n        Class: \"Article\", Properties: []*models.Property{prop},\n    }).Do(ctx) // create class with the property instead of patching\n}\nreturn client.Schema().PropertyCreator().WithClassName(\"Article\").WithProperty(prop).Do(ctx)","handlingStrategy":"try-catch","validationCode":"class, err := client.Schema().ClassGetter().WithClassName(\"Article\").Do(ctx)\nif err != nil || class == nil {\n    return fmt.Errorf(\"class Article does not exist; cannot add property\")\n}\n// proceed with PropertyCreator","typeGuard":"func indexExists(db IndexGetter, className string) bool {\n    return db.GetIndex(schema.ClassName(className)) != nil\n}","tryCatchPattern":"err := addProperty(ctx, className, prop)\nif err != nil {\n    if strings.Contains(err.Error(), \"non-existing index\") {\n        // recreate class including the property, or fix class name casing\n        return recreateClassWithProperty(ctx, className, prop)\n    }\n    return err\n}","preventionTips":["Always fetch the class schema before mutating it; treat names as case-sensitive.","Serialize schema mutations per class (avoid concurrent DELETE + PATCH).","In clusters, wait for schema convergence before issuing property changes."],"tags":["go","schema","migrator","index-not-found","concurrency"],"backgroundTag":"index-not-found","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"}