HKUDS/nanobot · error · RuntimeError

Mochat HTTP {response.status_code}: {response.text[:200]}

Error message

Mochat HTTP {response.status_code}: {response.text[:200]}

What it means

Error "Mochat HTTP {response.status_code}: {response.text[:200]}" thrown in HKUDS/nanobot.

Source

Thrown at nanobot/channels/mochat/runtime.py:959

            self._cursor_path.write_text(json.dumps({
                "schemaVersion": 1,
                "updatedAt": datetime.utcnow().isoformat(),  # pyright: ignore[reportDeprecated]
                "cursors": self._session_cursor,
            }, ensure_ascii=False, indent=2) + "\n", "utf-8")
        except Exception as e:
            self.logger.warning("Failed to save cursor file: {}", e)

    # ---- HTTP helpers ------------------------------------------------------

    async def _post_json(self, path: str, payload: dict[str, Any]) -> dict[str, Any]:
        if not self._http:
            raise RuntimeError("Mochat HTTP client not initialized")
        url = f"{self.config.base_url.strip().rstrip('/')}{path}"
        response = await self._http.post(url, headers={
            "Content-Type": "application/json", "X-Claw-Token": self.config.claw_token,
        }, json=payload)
        if not response.is_success:
            raise RuntimeError(f"Mochat HTTP {response.status_code}: {response.text[:200]}")
        try:
            parsed = response.json()
        except Exception:
            parsed = response.text
        if isinstance(parsed, dict):
            parsed_dict = cast(dict[str, Any], parsed)
            if isinstance(parsed_dict.get("code"), int):
                if parsed_dict["code"] != 200:
                    msg = str(
                        parsed_dict.get("message")
                        or parsed_dict.get("name")
                        or "request failed"
                    )
                    raise RuntimeError(
                        f"Mochat API error: {msg} (code={parsed_dict['code']})"
                    )
                data = parsed_dict.get("data")
                return cast(dict[str, Any], data) if isinstance(data, dict) else {}

View on GitHub (pinned to 42f37dc4c0)

When it happens

Trigger: Thrown at nanobot/channels/mochat/runtime.py:959 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/4fadb0c087f7c296. Report an issue: GitHub.