{"record":{"id":"f6cec2c97692fc28","repo":"weaviate/weaviate","slug":"desiredcount-is-limited-to-1-got-d","errorCode":null,"errorMessage":"desiredCount is limited to 1 (got %d)","messagePattern":"desiredCount is limited to 1 \\(got (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/schema/class.go","lineNumber":279,"sourceCode":"\t\treturn nil, 0, err\n\t}\n\treturn cls, version, err\n}\n\n// rejectExplicitMultiShardOnNamespacedClass rejects an explicit\n// desiredCount != 1. ParseConfig with nodeCount=1 folds default and\n// explicit-1 together; anything else came from the user. Parse errors\n// fall through to parser.ParseClass below.\nfunc rejectExplicitMultiShardOnNamespacedClass(shardingConfig any) error {\n\tif _, ok := shardingConfig.(map[string]interface{}); !ok {\n\t\treturn nil\n\t}\n\tcfg, err := shardingcfg.ParseConfig(shardingConfig, 1)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tif cfg.DesiredCount != 1 {\n\t\treturn fmt.Errorf(\"desiredCount is limited to 1 (got %d)\", cfg.DesiredCount)\n\t}\n\treturn nil\n}\n\n// namespaceCandidates returns the storage-candidate list for placing\n// qualifiedClass's shards. On NS-disabled clusters it returns the full\n// cluster candidates; on NS-enabled clusters it returns\n// [namespace.home_node] so every shard pins to that one node.\nfunc (h *Handler) namespaceCandidates(qualifiedClass string) ([]string, error) {\n\tif !h.config.Namespaces.Enabled {\n\t\treturn h.schemaManager.StorageCandidates(), nil\n\t}\n\tns := namespacing.NamespaceFromQualified(qualifiedClass)\n\tif ns == \"\" {\n\t\treturn nil, fmt.Errorf(\"expected namespace-qualified class name, got %q\", qualifiedClass)\n\t}\n\tgot, ok := h.namespacesExister.GetNamespace(ns)\n\tif !ok {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/schema/class.go#L261-L297","documentation":"rejectExplicitMultiShardOnNamespacedClass (invoked from AddClass) parses the shardingConfig with a maximum of 1 and rejects any class that explicitly requests desiredCount > 1 when it is not allowed (e.g. a namespaced/tenant-scoped class). Sharding is capped at one shard for such classes.","triggerScenarios":"POST /v1/schema with a class whose shardingConfig sets desiredCount to a value greater than 1 on a class where multi-sharding is prohibited (namespaced class).","commonSituations":"Copying a shardingConfig from a non-namespaced collection template; raising desiredCount for scale on a multi-tenant collection; older clients importing configs written for single-tenant classes.","solutions":["Set desiredCount to 1 (or omit shardingConfig to use defaults)","If you need multiple shards, make the class non-namespaced (disable multi-tenancy for it)","Use per-tenant partitioning (multi-tenancy) instead of multi-shard for scale","Move large tenant data to a dedicated non-namespaced collection"],"exampleFix":"// before\n\"shardingConfig\": {\"desiredCount\": 3}\n// after\n\"shardingConfig\": {\"desiredCount\": 1}","handlingStrategy":"validation","validationCode":"cfg, err := shardingcfg.ParseConfig(shardingConfig, 1)\nif err != nil { return err }\nif isNamespaced && cfg.DesiredCount != 1 { return fmt.Errorf(\"desiredCount must be 1, got %d\", cfg.DesiredCount) }","typeGuard":null,"tryCatchPattern":"_, err := client.Schema().ClassCreator().WithClass(c).Do(ctx)\nif err != nil && strings.Contains(err.Error(), \"desiredCount is limited to 1\") {\n  // drop shardingConfig or set desiredCount: 1 and retry\n}","preventionTips":["Omit shardingConfig for multi-tenant (namespaced) classes","Never copy sharding templates from single-tenant collections","Scale via tenants, not shards, for namespaced classes"],"tags":["validation","sharding","multi-tenancy"],"backgroundTag":"invalid-sharding-configuration","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"}