weaviate/weaviate · error

cannot have both shardingConfig and multiTenancyConfig

Error message

cannot have both shardingConfig and multiTenancyConfig

What it means

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.

Source

Thrown at usecases/schema/class.go:723

// provider's OnTaskCompleted clears the per-shard tokenization overlay
// immediately after this returns; without the local-apply wait the
// overlay would be cleared while this node's schema reader still has
// the OLD tokenization, opening a query-side misalignment window
// between local-apply and RAFT-commit on slow followers.
func UpdatePropertyInternalFromMigration(h *Handler, ctx context.Context, className string, prop *models.Property,
	fields ...string,
) error {
	setPropertyDefaults(prop)
	version, err := h.schemaManager.UpdatePropertyFromMigration(ctx, className, prop, fields...)
	if err != nil {
		return err
	}
	return h.schemaReader.WaitForUpdate(ctx, version)
}

func (m *Handler) setNewClassDefaults(class *models.Class, globalCfg replication.GlobalConfig) error {
	if class.ShardingConfig != nil && schema.MultiTenancyEnabled(class) {
		return fmt.Errorf("cannot have both shardingConfig and multiTenancyConfig")
	} else if class.MultiTenancyConfig == nil {
		class.MultiTenancyConfig = &models.MultiTenancyConfig{}
	} else if class.MultiTenancyConfig.Enabled {
		class.ShardingConfig = shardingcfg.Config{DesiredCount: 0} // tenant shards will be created dynamically
	}

	if err := m.setClassDefaults(class, globalCfg); err != nil {
		return err
	}

	if class.ReplicationConfig == nil {
		class.ReplicationConfig = &models.ReplicationConfig{
			Factor:           int64(m.config.Replication.MinimumFactor),
			DeletionStrategy: models.ReplicationConfigDeletionStrategyTimeBasedResolution,
		}
		return nil
	}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Remove shardingConfig from the class definition and keep multiTenancyConfig.enabled = true
  2. Or remove/disable multiTenancyConfig if you actually want static sharding
  3. Recreate the class definition payload from the multi-tenancy documentation template

Example fix

// before
{"class":"Article","shardingConfig":{"desiredCount":4},"multiTenancyConfig":{"enabled":true}}
// after
{"class":"Article","multiTenancyConfig":{"enabled":true}}
Defensive patterns

Strategy: validation

Validate before calling

if (cls.shardingConfig && cls.multiTenancyConfig?.enabled)
  throw new Error('Remove shardingConfig when multiTenancy is enabled');

Type guard

function isMtCompatible(cls) {
  return !(cls.shardingConfig != null && cls.multiTenancyConfig?.enabled === true);
}

Try / catch

try {
  await weaviate.schema.classCreator().withClass(cls).do();
} catch (e) {
  if (/cannot have both shardingConfig and multiTenancyConfig/.test(e.message)) {
    delete cls.shardingConfig;
    await weaviate.schema.classCreator().withClass(cls).do();
  } else throw e;
}

Prevention

When it happens

Trigger: POST /v1/schema with a class that sets both class.shardingConfig (non-nil, e.g. {desiredCount: 4}) and multiTenancyConfig: {enabled: true}.

Common situations: 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.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/692810055974e7c8. Report an issue: GitHub.