{"record":{"id":"fc4604610b8fc9eb","repo":"mem0ai/mem0","slug":"extra-fields-not-allowed-join-extra-fields-fc4604","errorCode":null,"errorMessage":"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}","messagePattern":"Extra fields not allowed: (.+?)\\. Please input only the following fields: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/elasticsearch.py","lineNumber":62,"sourceCode":"            # Check if headers is a dictionary\n            if not isinstance(headers, dict):\n                raise ValueError(\"headers must be a dictionary\")\n            \n            # Check if all keys and values are strings\n            for key, value in headers.items():\n                if not isinstance(key, str) or not isinstance(value, str):\n                    raise ValueError(\"All header keys and values must be strings\")\n        \n        return values\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        allowed_fields = set(cls.model_fields.keys())\n        input_fields = set(values.keys())\n        extra_fields = input_fields - allowed_fields\n        if extra_fields:\n            raise ValueError(\n                f\"Extra fields not allowed: {', '.join(extra_fields)}. \"\n                f\"Please input only the following fields: {', '.join(allowed_fields)}\"\n            )\n        return values\n\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n","sourceCodeStart":44,"sourceCodeEnd":69,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/elasticsearch.py#L44-L69","documentation":"Raised by the Elasticsearch config's strict extra-fields validator. Any key beyond the declared model fields is rejected, with the error listing extras and the allowed field set. It guards against typos and options that belong to the raw elasticsearch-py client rather than mem0's config surface.","triggerScenarios":"Passing ElasticsearchConfig keys such as 'ssl_verify', 'ca_certs', 'max_retries', 'request_timeout' — client kwargs that are not declared fields on this model.","commonSituations":"Copying an Elasticsearch() client constructor kwargs dict into mem0 config; version upgrades adding/renaming fields while old configs persist; mixing cloud and self-hosted option sets in one dict.","solutions":["Remove the extra key(s) from the config as listed in the error","For advanced client options, construct the ES client yourself and pass supported fields only","Validate config keys against the allowed list printed in the error message","After upgrading mem0, smoke-test saved vector store configs to catch renamed fields"],"exampleFix":"# before\nElasticsearchConfig(host=\"h\", api_key=\"k\", max_retries=5)\n\n# after\nElasticsearchConfig(host=\"h\", api_key=\"k\")","handlingStrategy":"validation","validationCode":"from mem0.configs.vector_stores.elasticsearch import ElasticsearchConfig\ndef prune_es_extra(cfg: dict) -> dict:\n    extra = set(cfg) - set(ElasticsearchConfig.model_fields)\n    if extra:\n        raise RuntimeError(f\"Unexpected elasticsearch keys: {sorted(extra)}\")\n    return cfg","typeGuard":"def es_keys_valid(cfg: dict) -> bool:\n    return not (set(cfg) - set(ElasticsearchConfig.model_fields))","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    ElasticsearchConfig(**cfg)\nexcept ValidationError as e:\n    if \"Extra fields not allowed\" in str(e):\n        # remove client-only kwargs listed in the message\n        ...","preventionTips":["Do not copy elasticsearch-py constructor kwargs into mem0 config","Keep a per-provider allowed-keys constant in your codebase","Smoke-test configs after upgrading mem0"],"tags":["pydantic","configuration","vector-store","elasticsearch","strict-schema"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}