{"record":{"id":"2d58ea70e4fa8d12","repo":"666ghj/MiroFish","slug":"zep-api-key-2d58ea","errorCode":null,"errorMessage":"ZEP_API_KEY 未配置","messagePattern":"ZEP_API_KEY 未配置","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/zep_tools.py","lineNumber":433,"sourceCode":"    \n    【基础工具】\n    - search_graph - 图谱语义搜索\n    - get_all_nodes - 获取图谱所有节点\n    - get_all_edges - 获取图谱所有边（含时间信息）\n    - get_node_detail - 获取节点详细信息\n    - get_node_edges - 获取节点相关的边\n    - get_entities_by_type - 按类型获取实体\n    - get_entity_summary - 获取实体的关系摘要\n    \"\"\"\n    \n    # 重试配置\n    MAX_RETRIES = 3\n    RETRY_DELAY = 2.0\n    \n    def __init__(self, api_key: Optional[str] = None, llm_client: Optional[LLMClient] = None):\n        self.api_key = api_key or Config.ZEP_API_KEY\n        if not self.api_key:\n            raise ValueError(\"ZEP_API_KEY 未配置\")\n        \n        self.client = get_zep_client(self.api_key)\n        # LLM客户端用于InsightForge生成子问题\n        self._llm_client = llm_client\n        logger.info(t(\"console.zepToolsInitialized\"))\n    \n    @property\n    def llm(self) -> LLMClient:\n        \"\"\"延迟初始化LLM客户端\"\"\"\n        if self._llm_client is None:\n            self._llm_client = LLMClient()\n        return self._llm_client\n    \n    def _call_with_retry(self, func, operation_name: str, max_retries: int = None):\n        \"\"\"Retry one safe read using typed Zep/HTTPX error classification.\"\"\"\n\n        return call_zep_read_with_retry(\n            func,","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/zep_tools.py#L415-L451","documentation":"ValueError raised in ZepTools.__init__ when neither the constructor argument api_key nor Config.ZEP_API_KEY is set. The tools wrapper requires a Zep Cloud API key to construct its client (get_zep_client), so initialization refuses to proceed rather than failing later on every request.","triggerScenarios":"Instantiating ZepTools() (or anything that constructs it, e.g. graph search tooling) in an environment where the ZEP_API_KEY environment variable/config entry is absent or empty string.","commonSituations":"Missing .env entry, deployment where env vars are not passed to the container/process, CI runs without secrets, or a typo in the variable name in Config.","solutions":["Set ZEP_API_KEY in the environment or config file used by Config before constructing ZepTools","Pass api_key explicitly: ZepTools(api_key=os.environ['ZEP_API_KEY'])","Fail fast at startup: validate required config keys once during boot instead of at first use"],"exampleFix":"# before\ntools = ZepTools()  # ZEP_API_KEY unset -> ValueError\n\n# after\napi_key = os.environ.get(\"ZEP_API_KEY\")\nif not api_key:\n    raise SystemExit(\"ZEP_API_KEY is required\")\ntools = ZepTools(api_key=api_key)","handlingStrategy":"validation","validationCode":"if not (api_key or Config.ZEP_API_KEY):\n    raise SystemExit(\"ZEP_API_KEY is required before using Zep tools\")","typeGuard":null,"tryCatchPattern":"try:\n    tools = ZepTools(api_key=key)\nexcept ValueError as e:\n    logger.error(\"config error: %s\", e)\n    raise","preventionTips":["Validate required secrets once at startup with a clear missing-key report","Keep .env.example in sync with required keys","Inject secrets via the environment/secret manager, never hardcode"],"tags":["configuration","zep","api-key","startup"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}