{"record":{"id":"19fef8017ff49007","repo":"666ghj/MiroFish","slug":"zep-api-key-19fef8","errorCode":null,"errorMessage":"ZEP_API_KEY 未配置","messagePattern":"ZEP_API_KEY 未配置","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/zep_entity_reader.py","lineNumber":83,"sourceCode":"            \"total_count\": self.total_count,\n            \"filtered_count\": self.filtered_count,\n        }\n\n\nclass ZepEntityReader:\n    \"\"\"\n    Zep实体读取与过滤服务\n    \n    主要功能：\n    1. 从Zep图谱读取所有节点\n    2. 筛选出符合预定义实体类型的节点（Labels不只是Entity的节点）\n    3. 获取每个实体的相关边和关联节点信息\n    \"\"\"\n    \n    def __init__(self, api_key: Optional[str] = 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    \n    def _call_with_retry(\n        self, \n        func: Callable[[], T], \n        operation_name: str,\n        max_retries: int = 3,\n        initial_delay: float = 2.0\n    ) -> T:\n        \"\"\"\n        带重试机制的Zep API调用\n        \n        Args:\n            func: 要执行的函数（无参数的lambda或callable）\n            operation_name: 操作名称，用于日志\n            max_retries: 最大重试次数（默认3次，即最多尝试3次）\n            initial_delay: 初始延迟秒数","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/zep_entity_reader.py#L65-L101","documentation":"ZepEntityReader.__init__ requires a Zep API key: it falls back from the constructor argument to Config.ZEP_API_KEY, and if neither is set it raises ValueError('ZEP_API_KEY 未配置') before creating the Zep client. Every entity/graph read this service performs is blocked until the key is supplied.","triggerScenarios":"Instantiating ZepEntityReader() (directly or via a graph-analysis endpoint) in an environment where the ZEP_API_KEY env var / config entry is unset or empty and no api_key argument is passed.","commonSituations":"Missing entry in .env / deployment secrets; CI runs without Zep credentials; key name typo (ZEP_APIKEY, ZEP_KEY); empty-string value counts as unset.","solutions":["Set ZEP_API_KEY in the backend environment (.env or secret manager) and restart the backend.","Alternatively pass api_key explicitly: ZepEntityReader(api_key=os.environ['ZEP_TOKEN']).","Verify with a minimal snippet that Config.ZEP_API_KEY loads (non-empty) before starting dependent jobs."],"exampleFix":"# before\nreader = ZepEntityReader()  # ValueError: ZEP_API_KEY 未配置\n\n# after\n# .env\nZEP_API_KEY=zep_live_xxxxxxxx\nreader = ZepEntityReader()","handlingStrategy":"validation","validationCode":"def zep_key_configured() -> bool:\n    return bool(Config.ZEP_API_KEY)","typeGuard":null,"tryCatchPattern":"try:\n    reader = ZepEntityReader()\nexcept ValueError as e:\n    if \"ZEP_API_KEY\" in str(e):\n        raise HTTPException(503, detail=\"graph analysis unavailable: ZEP not configured\")\n    raise","preventionTips":["Add a startup readiness check that fails fast when graph features are enabled without ZEP_API_KEY.","Centralize the key check in Config so all Zep services share one guard.","Include the key in smoke tests for deployments that use graph memory."],"tags":["zep","configuration","missing-api-key","graph-memory"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}