{"record":{"id":"92921c094f012d05","repo":"bytedance/deer-flow","slug":"mem0-failure-policy-has-unknown-keys-sorted-unkn","errorCode":null,"errorMessage":"mem0 failure_policy has unknown keys: {sorted(unknown_fp)}","messagePattern":"mem0 failure_policy has unknown keys: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/backends/mem0/config.py","lineNumber":79,"sourceCode":"            - {\n                \"api_key_env\",\n                \"base_url\",\n                \"allow_insecure_http\",\n                \"top_k\",\n                \"score_threshold\",\n                \"max_injection_chars\",\n                \"timeout_seconds\",\n                \"startup_policy\",\n            }\n            - _HOST_INJECTED_KEYS\n        )\n        if unknown:\n            raise ValueError(f\"mem0 backend_config has unknown keys: {sorted(unknown)}\")\n        if not isinstance(failure_policy, dict):\n            raise ValueError(\"mem0 failure_policy must be a mapping {read, write}\")\n        unknown_fp = set(failure_policy) - {\"read\", \"write\"}\n        if unknown_fp:\n            raise ValueError(f\"mem0 failure_policy has unknown keys: {sorted(unknown_fp)}\")\n        allow_insecure_http = cfg.get(\"allow_insecure_http\", False)\n        if not isinstance(allow_insecure_http, bool):\n            raise ValueError(\"mem0 allow_insecure_http must be a boolean\")\n\n        config = cls(\n            api_key_env=str(cfg.get(\"api_key_env\", \"MEM0_API_KEY\")),\n            base_url=str(cfg.get(\"base_url\", \"https://api.mem0.ai\")).rstrip(\"/\"),\n            allow_insecure_http=allow_insecure_http,\n            top_k=int(cfg.get(\"top_k\", 8)),\n            score_threshold=float(cfg.get(\"score_threshold\", 0.1)),\n            max_injection_chars=int(cfg.get(\"max_injection_chars\", 12000)),\n            timeout_seconds=float(cfg.get(\"timeout_seconds\", 10.0)),\n            startup_policy=str(cfg.get(\"startup_policy\", \"fail_fast\")),\n            read_policy=str(failure_policy.get(\"read\", \"fail_open\")),\n            write_policy=str(failure_policy.get(\"write\", \"log_and_drop\")),\n        )\n        if config.startup_policy not in _STARTUP_POLICIES:\n            raise ValueError(f\"mem0 startup_policy must be one of {sorted(_STARTUP_POLICIES)}\")","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/mem0/config.py#L61-L97","documentation":"Raised by Mem0Config.from_backend_config when memory.backend_config.failure_policy is a mapping but contains keys other than the two supported directions: read and write. Unknown keys are rejected so that a typo like reads or right does not silently disable a policy the operator believed was active.","triggerScenarios":"failure_policy: {read: fail_open, writes: log_and_drop} — 'writes' is rejected; also extra invented keys like failure_policy: {read: ..., write: ..., startup: ...}.","commonSituations":"Typo in read/write key names; copy-pasting a policy block from another backend or older docs with extra keys; assuming failure_policy also carries startup_policy-style options.","solutions":["Rename the offending key to read or write — the sorted list in the message names exactly which keys are invalid","Move non-policy options where they belong (e.g. startup_policy is a top-level backend_config key)","Remove keys you do not need; read and write each have safe defaults"],"exampleFix":"# before (config.yaml)\nmemory:\n  backend_config:\n    failure_policy:\n      read: fail_open\n      writes: log_and_drop   # typo -> ValueError\n\n# after\nmemory:\n  backend_config:\n    failure_policy:\n      read: fail_open\n      write: log_and_drop","handlingStrategy":"validation","validationCode":"def failure_policy_keys_ok(backend_config: dict) -> bool:\n    fp = (backend_config or {}).get(\"failure_policy\") or {}\n    return isinstance(fp, dict) and set(fp) <= {\"read\", \"write\"}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["failure_policy has exactly two keys: read and write — nothing else","startup behavior belongs in the top-level startup_policy key, not inside failure_policy"],"tags":["config","mem0","memory","yaml","validation"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}