{"record":{"id":"692810055974e7c8","repo":"weaviate/weaviate","slug":"cannot-have-both-shardingconfig-and-multitenancyco","errorCode":null,"errorMessage":"cannot have both shardingConfig and multiTenancyConfig","messagePattern":"cannot have both shardingConfig and multiTenancyConfig","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/schema/class.go","lineNumber":723,"sourceCode":"// provider's OnTaskCompleted clears the per-shard tokenization overlay\n// immediately after this returns; without the local-apply wait the\n// overlay would be cleared while this node's schema reader still has\n// the OLD tokenization, opening a query-side misalignment window\n// between local-apply and RAFT-commit on slow followers.\nfunc UpdatePropertyInternalFromMigration(h *Handler, ctx context.Context, className string, prop *models.Property,\n\tfields ...string,\n) error {\n\tsetPropertyDefaults(prop)\n\tversion, err := h.schemaManager.UpdatePropertyFromMigration(ctx, className, prop, fields...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn h.schemaReader.WaitForUpdate(ctx, version)\n}\n\nfunc (m *Handler) setNewClassDefaults(class *models.Class, globalCfg replication.GlobalConfig) error {\n\tif class.ShardingConfig != nil && schema.MultiTenancyEnabled(class) {\n\t\treturn fmt.Errorf(\"cannot have both shardingConfig and multiTenancyConfig\")\n\t} else if class.MultiTenancyConfig == nil {\n\t\tclass.MultiTenancyConfig = &models.MultiTenancyConfig{}\n\t} else if class.MultiTenancyConfig.Enabled {\n\t\tclass.ShardingConfig = shardingcfg.Config{DesiredCount: 0} // tenant shards will be created dynamically\n\t}\n\n\tif err := m.setClassDefaults(class, globalCfg); err != nil {\n\t\treturn err\n\t}\n\n\tif class.ReplicationConfig == nil {\n\t\tclass.ReplicationConfig = &models.ReplicationConfig{\n\t\t\tFactor:           int64(m.config.Replication.MinimumFactor),\n\t\t\tDeletionStrategy: models.ReplicationConfigDeletionStrategyTimeBasedResolution,\n\t\t}\n\t\treturn nil\n\t}\n","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/schema/class.go#L705-L741","documentation":"A class may not declare both a custom shardingConfig and multiTenancy enabled: multi-tenancy manages its own per-tenant sharding dynamically, so the two configurations are mutually exclusive. setNewClassDefaults rejects the combination at AddClass time.","triggerScenarios":"POST /v1/schema with a class that sets both class.shardingConfig (non-nil, e.g. {desiredCount: 4}) and multiTenancyConfig: {enabled: true}.","commonSituations":"Migrating a pre-MT class definition to multi-tenancy while leaving the old shardingConfig in place; copying a class definition from a non-MT collection and flipping multiTenancy enabled; generated clients that always emit shardingConfig defaults.","solutions":["Remove shardingConfig from the class definition and keep multiTenancyConfig.enabled = true","Or remove/disable multiTenancyConfig if you actually want static sharding","Recreate the class definition payload from the multi-tenancy documentation template"],"exampleFix":"// before\n{\"class\":\"Article\",\"shardingConfig\":{\"desiredCount\":4},\"multiTenancyConfig\":{\"enabled\":true}}\n// after\n{\"class\":\"Article\",\"multiTenancyConfig\":{\"enabled\":true}}","handlingStrategy":"validation","validationCode":"if (cls.shardingConfig && cls.multiTenancyConfig?.enabled)\n  throw new Error('Remove shardingConfig when multiTenancy is enabled');","typeGuard":"function isMtCompatible(cls) {\n  return !(cls.shardingConfig != null && cls.multiTenancyConfig?.enabled === true);\n}","tryCatchPattern":"try {\n  await weaviate.schema.classCreator().withClass(cls).do();\n} catch (e) {\n  if (/cannot have both shardingConfig and multiTenancyConfig/.test(e.message)) {\n    delete cls.shardingConfig;\n    await weaviate.schema.classCreator().withClass(cls).do();\n  } else throw e;\n}","preventionTips":["Use a multi-tenancy class template without shardingConfig","When migrating to MT, explicitly delete shardingConfig from the JSON","Lint schema files for mutually exclusive fields"],"tags":["schema","multitenancy","sharding","weaviate"],"backgroundTag":"conflicting-sharding-config","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"}