{"record":{"id":"0ba09c2e963279d6","repo":"mem0ai/mem0","slug":"invalid-json-in-metadata-field","errorCode":null,"errorMessage":"Invalid JSON in \"Metadata\" field","messagePattern":"Invalid JSON in \"Metadata\" field","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts","lineNumber":426,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\tconst addFields = this.getNodeParameter('addFields', i, {}) as IDataObject;\n\t\t\t\t\tconst body: IDataObject = {\n\t\t\t\t\t\tmessages: messagesUi.map((m) => ({ role: m.role, content: m.content })),\n\t\t\t\t\t\tinfer: addFields.infer !== undefined ? addFields.infer : true,\n\t\t\t\t\t};\n\t\t\t\t\tconst userId = this.getNodeParameter('userId', i, '') as string;\n\t\t\t\t\tif (userId) body.user_id = userId;\n\t\t\t\t\tif (addFields.agent_id) body.agent_id = addFields.agent_id;\n\t\t\t\t\tif (addFields.app_id) body.app_id = addFields.app_id;\n\t\t\t\t\tif (addFields.run_id) body.run_id = addFields.run_id;\n\t\t\t\t\tif (addFields.metadata) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tbody.metadata =\n\t\t\t\t\t\t\t\ttypeof addFields.metadata === 'string'\n\t\t\t\t\t\t\t\t\t? JSON.parse(addFields.metadata as string)\n\t\t\t\t\t\t\t\t\t: addFields.metadata;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Invalid JSON in \"Metadata\" field', {\n\t\t\t\t\t\t\t\titemIndex: i,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Custom extraction controls (optional): steer what the API extracts.\n\t\t\t\t\tif (addFields.custom_instructions) {\n\t\t\t\t\t\tbody.custom_instructions = addFields.custom_instructions;\n\t\t\t\t\t}\n\t\t\t\t\tif (addFields.custom_categories) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tbody.custom_categories =\n\t\t\t\t\t\t\t\ttypeof addFields.custom_categories === 'string'\n\t\t\t\t\t\t\t\t\t? JSON.parse(addFields.custom_categories as string)\n\t\t\t\t\t\t\t\t\t: addFields.custom_categories;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tthis.getNode(),","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts#L408-L444","documentation":"A 400 raised by _validate_bundled_providers when the submitted config specifies an LLM provider (config['llm']['provider']) that is not in BUNDLED_LLM_PROVIDERS for this server image. The Docker image only ships the Python packages for a fixed list of providers; requesting any other provider cannot work at runtime, so the server rejects the config up front with instructions to extend the image.","triggerScenarios":"POST/PUT of a config with e.g. \"llm\": {\"provider\": \"anthropic\"} when 'anthropic' is not in the image's BUNDLED_LLM_PROVIDERS; migrating a config from a pip-installed deployment (which could install any provider) to the prebuilt Docker image; a typo in the provider name.","commonSituations":"Self-hosting the official container and wanting a provider the image does not bundle; a new provider exists in mem0ai on PyPI but the Docker image predates it; copying an example config that uses a niche provider.","solutions":["Check the bundled list in the error message and switch config['llm']['provider'] to one of those (e.g. 'openai').","Or build a custom image: pip install the provider's package in the Dockerfile and extend BUNDLED_LLM_PROVIDERS in server/main.py, then rebuild.","Or run the server from source (pip install mem0ai[<provider>] plus the server package) instead of the prebuilt image.","Verify the provider string matches exactly (lowercase, no extra spaces) what mem0 expects."],"exampleFix":"# before\n{\"llm\": {\"provider\": \"anthropic\", \"config\": {\"model\": \"claude-3-5-sonnet\"}}}\n\n# after (image bundles openai)\n{\"llm\": {\"provider\": \"openai\", \"config\": {\"model\": \"gpt-4o-mini\", \"api_key\": \"...\"}}}","handlingStrategy":"validation","validationCode":"BUNDLED_LLM_PROVIDERS = {\"openai\", \"azure_openai\", \"anthropic\", \"gemini\"}  # mirror the image's list\n\ndef validate_llm_config(cfg: dict) -> None:\n    llm = cfg.get(\"llm\") or {}\n    provider = llm.get(\"provider\", \"openai\")\n    if provider not in BUNDLED_LLM_PROVIDERS:\n        raise ValueError(f\"LLM provider '{provider}' not bundled; pick from {sorted(BUNDLED_LLM_PROVIDERS)}\")","typeGuard":"def is_bundled_llm(provider: str, bundled: set[str]) -> bool:\n    return provider in bundled","tryCatchPattern":"if resp.status_code == 400 and \"not bundled\" in resp.text:\n    raise ConfigError(resp.json()[\"detail\"])  # config error, not transient: do not retry","preventionTips":["Pin the bundled provider list in deployment config and validate before submit.","Document which providers the shipped image supports in your project README.","When building custom images, extend BUNDLED_LLM_PROVIDERS in the same commit that installs the package."],"tags":["configuration","llm-provider","docker","http-400","rest-server"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}