mem0ai/mem0 · error · ValueError

Extra fields not allowed: {', '.join(extra_fields)}. Please

Error message

Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}

What it means

The Valkey config model closes its field set: only the declared Valkey options (connection settings plus HNSW knobs hnsw_m, hnsw_ef_construction, hnsw_ef_runtime, cluster_mode, collection_name, embedding_model_dims, and neighbors) are accepted. A `before` model_validator computes set(keys) - set(model_fields) and raises this error listing the extras and the allowed names.

Source

Thrown at mem0/configs/vector_stores/valkey.py:26

    valkey_url: str = Field(..., description="Valkey server URL (e.g., redis://localhost:6379)")
    collection_name: str = Field(..., description="Name of the index / collection")
    embedding_model_dims: int = Field(..., description="Dimensions of the embedding model")
    timezone: str = Field("UTC", description="Timezone for timestamp handling")
    index_type: str = Field("hnsw", description="Index type: 'hnsw' (default) or 'flat'")
    hnsw_m: int = Field(16, description="HNSW: number of connections per layer")
    hnsw_ef_construction: int = Field(200, description="HNSW: search width during index construction")
    hnsw_ef_runtime: int = Field(10, description="HNSW: search width during queries")
    cluster_mode: bool = Field(False, description="Enable cluster mode for Valkey cluster (CME) deployments")

    @model_validator(mode="before")
    @classmethod
    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        allowed_fields = set(cls.model_fields.keys())
        input_fields = set(values.keys())
        extra_fields = input_fields - allowed_fields
        if extra_fields:
            raise ValueError(
                f"Extra fields not allowed: {', '.join(extra_fields)}. "
                f"Please input only the following fields: {', '.join(allowed_fields)}"
            )
        return values

    model_config = ConfigDict(arbitrary_types_allowed=False)

View on GitHub (pinned to 001c235229)

Solutions

  1. Strip the config down to the allowed fields named in the error message
  2. Use the valkey-specific key names (valkey_url / host+port as declared) rather than the redis_* spellings
  3. Prefix HNSW options exactly as declared: hnsw_m, hnsw_ef_construction, hnsw_ef_runtime

Example fix

# before
config = {"redis_url": "redis://localhost:6379", "ef_construction": 200}

# after
config = {"host": "localhost", "port": 6379, "hnsw_ef_construction": 200}
Defensive patterns

Strategy: validation

Validate before calling

from mem0.configs.vector_stores.valkey import ValkeyDBConfig  # name per repo
extra = set(cfg) - set(ValkeyDBConfig.model_fields)
if extra:
    raise ConfigError(f"unknown valkey config keys: {sorted(extra)}")

Prevention

When it happens

Trigger: Passing Redis-style keys (redis_url) or auth fields in a valkey config; misspelling hnsw fields (e.g. 'ef_construction' without the hnsw_ prefix); including keys from the Redis config template since Valkey is Redis-compatible.

Common situations: Treating the valkey provider config as identical to the redis provider config; copying HNSW tuning from Valkey docs that use bare parameter names; version drift after a field rename.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/f5a9d26e72478ed9. Report an issue: GitHub.