{"record":{"id":"6a3a0319d4d4e89a","repo":"666ghj/MiroFish","slug":"zep-api-key-6a3a03","errorCode":null,"errorMessage":"ZEP_API_KEY未配置","messagePattern":"ZEP_API_KEY未配置","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/zep_graph_memory_updater.py","lineNumber":261,"sourceCode":"    def __init__(\n        self,\n        graph_id: str,\n        api_key: Optional[str] = None,\n        simulation_id: Optional[str] = None,\n    ):\n        \"\"\"\n        初始化更新器\n        \n        Args:\n            graph_id: Zep图谱ID\n            api_key: Zep API Key（可选，默认从配置读取）\n        \"\"\"\n        self.graph_id = graph_id\n        self.simulation_id = simulation_id or \"unknown\"\n        self.api_key = api_key or Config.ZEP_API_KEY\n        \n        if not self.api_key:\n            raise ValueError(\"ZEP_API_KEY未配置\")\n        \n        self.client = get_zep_client(self.api_key)\n        \n        # 活动队列\n        self._activity_queue: Queue = Queue()\n        \n        # 按平台分组的活动缓冲区（每个平台各自累积到BATCH_SIZE后批量发送）\n        self._platform_buffers: Dict[str, List[AgentActivity]] = {\n            'twitter': [],\n            'reddit': [],\n        }\n        self._buffer_lock = threading.Lock()\n        self._acceptance_lock = threading.Lock()\n        \n        # 控制标志\n        self._running = False\n        self._worker_thread: Optional[threading.Thread] = None\n        ","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/zep_graph_memory_updater.py#L243-L279","documentation":"ZepGraphMemoryUpdater.__init__ mirrors the reader's key check: graph_id plus optional api_key, falling back to Config.ZEP_API_KEY; when empty it raises ValueError('ZEP_API_KEY未配置') (note: no space, unlike the reader's message) before building the Zep client and its activity queue. Any simulation started with graph memory enabled will fail at updater construction without the key.","triggerScenarios":"Starting a simulation with graph memory (Zep) enabled while ZEP_API_KEY is unset in the backend process; constructing the updater programmatically without api_key; deploying with a different env file than the one containing the key.","commonSituations":"Graph-memory feature toggled on before credentials were provisioned; secrets not mounted in container deployments; local dev .env not loaded.","solutions":["Provision ZEP_API_KEY (Zep Cloud project key) in the backend's environment and restart.","If you did not intend to use graph memory, disable the Zep/graph-memory option in the simulation config so the updater is never constructed.","Check for whitespace/quotes around the value in .env — it must be a non-empty string."],"exampleFix":"# before\nupdater = ZepGraphMemoryUpdater(graph_id=\"sim_42\", simulation_id=\"sim_42\")  # ValueError\n\n# after\n# export ZEP_API_KEY=zep_live_xxx  (or set in .env)\nupdater = ZepGraphMemoryUpdater(graph_id=\"sim_42\", simulation_id=\"sim_42\")\n# or explicitly:\nupdater = ZepGraphMemoryUpdater(graph_id=\"sim_42\", simulation_id=\"sim_42\", api_key=os.environ[\"ZEP_API_KEY\"])","handlingStrategy":"validation","validationCode":"def can_enable_graph_memory() -> bool:\n    return bool(Config.ZEP_API_KEY)","typeGuard":null,"tryCatchPattern":"try:\n    ZepGraphMemoryManager.start_updater(sim_id, graph_id)\nexcept ValueError as e:\n    if \"ZEP_API_KEY\" in str(e):\n        disable_graph_memory(sim_id)  # degrade gracefully or fail the start request\n        raise HTTPException(400, detail=\"ZEP_API_KEY required for graph memory\")\n    raise","preventionTips":["Reject start requests that enable graph memory when ZEP_API_KEY is unset.","Verify secrets are mounted before deploying graph-memory-enabled configs.","Log the effective config source (which .env) at startup."],"tags":["zep","configuration","missing-api-key","graph-memory","updater"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}