can1357/oh-my-pi · error · RpcCommandError
{response.get("code") if str else null}
{response.get("code") if str else null}
Error message
{response.get("error", "")} What it means
RpcCommandError raised when the server responded success=false for a command. It carries the failing command name, the server-provided error string (response['error'], empty string if absent), and an optional string code from response['code'] (None if the code isn't a string).
Source
Thrown at python/omp-rpc/src/omp_rpc/client.py:1408
with self._state_lock:
self._pending.pop(request_id, None)
raise
try:
response = response_queue.get(timeout=self._request_timeout)
except queue.Empty as exc:
with self._state_lock:
self._pending.pop(request_id, None)
raise RpcTimeoutError(
f"Timed out waiting for response to {command_type}. Stderr: {self.stderr}"
) from exc
if isinstance(response, BaseException):
raise response
if not bool(response.get("success", False)):
raw_code = response.get("code")
raise RpcCommandError(
command=str(response.get("command", command_type)),
error=str(response.get("error", "")),
code=raw_code if isinstance(raw_code, str) else None,
)
data = response.get("data")
if data is None:
return {}
return _clone_json_object(data)
def _send_notification(self, payload: JsonObject) -> None:
process = self._require_process()
self._write_json(process, payload)
def _normalize_host_tool_result(self, result: object) -> JsonObject:
if isinstance(result, str):
return {"content": [{"type": "text", "text": result}]}
if isinstance(result, Mapping):View on GitHub (pinned to 9690622007)
Solutions
- Read exc.error (and exc.code) for the server's specific reason and fix the request payload accordingly
- Verify the command name and arguments against the server's protocol version
- Catch RpcCommandError around _request-style calls and branch on code where the server defines codes
- Update client and server packages together if a protocol mismatch causes systematic rejections
Example fix
try:
client.set_model("gpt-5")
except RpcCommandError as exc:
if exc.code == "model-not-found":
client.set_model("gpt-5-mini")
else:
raise Defensive patterns
Strategy: try-catch
Validate before calling
# validate payload keys/types against the protocol before sending
def validate_command(name: str, payload: dict) -> None:
required = COMMAND_SCHEMAS[name]
missing = required.keys() - payload.keys()
if missing:
raise ValueError(f"missing args: {missing}") Try / catch
try:
client.run_command("set_model", model=model_id)
except RpcCommandError as exc:
match exc.code:
case "model-not-found": pick_fallback_model()
case _: raise Prevention
- Log exc.command, exc.error, exc.code on every RpcCommandError
- Keep client and server protocol versions in lockstep
- Validate command payloads against the documented schema before sending
When it happens
Trigger: Any _request command the server rejects: invalid arguments, unknown command, session errors, server-side validation failures. The error text comes verbatim from the server payload.
Common situations: Calling commands with wrong payload shapes after a protocol version change; referencing a missing session/model; server-side tool or permission denials.
Related errors
- Replacement text is not valid UTF-8: {err}
- invalid glob `{pattern}`: {error}
- RPC chunk received before protocol negotiation
- RPC protocol v2 negotiation failed
- RPC command failed
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/d2c01e35b699f39b.
Report an issue: GitHub.