{"record":{"id":"b9c6fa9d4d58ce1f","repo":"BigPizzaV3/CodexPlusPlus","slug":"method-msg-error","errorCode":null,"errorMessage":"{method} 失败：{msg['error']}","messagePattern":"\\{method\\} 失败：\\{msg\\['error'\\]\\}","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/codex-wechat/codex_wechat.py","lineNumber":454,"sourceCode":"        self.proc.stdin.write(json.dumps(message, ensure_ascii=False) + \"\\n\")\n        self.proc.stdin.flush()\n\n    def _request(self, method: str, params: Any, timeout: int | None = None) -> dict[str, Any]:\n        req_id = self.next_id\n        self.next_id += 1\n        self._send({\"id\": req_id, \"method\": method, \"params\": params})\n\n        deadline = time.time() + (timeout or self.cfg.codex.timeout_seconds)\n        while time.time() < deadline:\n            try:\n                msg = self.messages.get(timeout=0.5)\n            except queue.Empty:\n                if self.proc and self.proc.poll() is not None:\n                    raise RuntimeError(f\"app-server 已退出，退出码 {self.proc.returncode}\")\n                continue\n            if msg.get(\"id\") == req_id:\n                if \"error\" in msg:\n                    raise RuntimeError(f\"{method} 失败：{msg['error']}\")\n                return msg.get(\"result\") or {}\n            # 其它通知留给当前请求外的事件循环自然丢弃。\n        raise TimeoutError(f\"{method} 超时\")\n\n    def _ensure_thread(self, user_id: str) -> str:\n        thread_id = self.threads.get(user_id)\n        if thread_id:\n            return thread_id\n\n        params: dict[str, Any] = {\n            \"cwd\": self.cfg.codex.workspace,\n            \"approvalPolicy\": self.cfg.codex.approval_policy,\n            \"sandbox\": self.cfg.codex.sandbox,\n            \"ephemeral\": True,\n            \"baseInstructions\": \"你是运行在微信里的 Codex 助手。全程中文，只把最终答复发给微信用户。\",\n        }\n        if self.cfg.codex.model:\n            params[\"model\"] = self.cfg.codex.model","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/codex-wechat/codex_wechat.py#L436-L472","documentation":"_request received an explicit JSON-RPC error response from the app-server (msg contains an 'error' object) and re-raises it wrapped with the method name. This is a server-side rejection of the call (e.g. invalid params, unsupported method, internal error), not a transport failure.","triggerScenarios":"Thrown at tools/codex-wechat/codex_wechat.py:454 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the embedded error object in the message for the server's code and message; fix the params passed to the method accordingly.","Check codex app-server version compatibility if the error says the method is unknown.","Surface the error to the caller (e.g. WeChat reply) instead of silently dropping the turn."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}