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

Raised by the Faiss config's strict extra-fields validator. Keys not declared on FaissConfig are rejected with an error that lists both the offending keys and the complete allowed field set. It prevents silently-ignored typos in a config surface that is otherwise small.

Source

Thrown at mem0/configs/vector_stores/faiss.py:32

    )
    embedding_model_dims: int = Field(1536, description="Dimension of the embedding vector")

    @model_validator(mode="before")
    @classmethod
    def validate_distance_strategy(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        distance_strategy = values.get("distance_strategy")
        if distance_strategy and distance_strategy not in ["euclidean", "inner_product", "cosine"]:
            raise ValueError("Invalid distance_strategy. Must be one of: 'euclidean', 'inner_product', 'cosine'")
        return values

    @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)}. Please input only the following fields: {', '.join(allowed_fields)}"
            )
        return values

    model_config = ConfigDict(arbitrary_types_allowed=True)

View on GitHub (pinned to 001c235229)

Solutions

  1. Remove the extra key(s) named in the error message
  2. Check remaining keys against the allowed list embedded in the error text
  3. Tune FAISS beyond exposed fields by building/managing the index outside the config
  4. Re-validate configs against your installed mem0 version after any upgrade

Example fix

# before
FaissConfig(distance_strategy="cosine", nlist=100)

# after
FaissConfig(distance_strategy="cosine")
Defensive patterns

Strategy: validation

Validate before calling

from mem0.configs.vector_stores.faiss import FaissConfig
def prune_faiss_extra(cfg: dict) -> dict:
    extra = set(cfg) - set(FaissConfig.model_fields)
    if extra:
        raise RuntimeError(f"Unexpected faiss keys: {sorted(extra)}")
    return cfg

Type guard

def faiss_keys_valid(cfg: dict) -> bool:
    return not (set(cfg) - set(FaissConfig.model_fields))

Try / catch

from pydantic import ValidationError
try:
    FaissConfig(**cfg)
except ValidationError as e:
    if "Extra fields not allowed" in str(e):
        # drop FAISS tuning params not exposed by the model
        ...

Prevention

When it happens

Trigger: Passing FaissConfig keys like 'nlist', 'nprobe', 'index_type', or any FAISS tuning parameter that is not a declared field of the model.

Common situations: Transcribing FAISS IndexIVFFlat constructor params into the config; carrying fields over from another vector store's config block; stale keys after a mem0 upgrade changed the field set.

Related errors


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