⚠️ Potential issue | 🟠 Major
Error handling catches PermissionError and ValueError but not httpx exceptions.
If _call_neurorift fails with network errors (e.g., httpx.RequestError, httpx.HTTPStatusError), they propagate uncaught, potentially crashing the message handler.
Add httpx exception handling
except ValueError as exc:
return {
"type": "rpc.response",
"id": correlation_id,
"session": {"id": session_ctx["sessionKey"], "mode": "isolated"},
"error": {"code": "invalid_request", "message": str(exc)},
}
+ except httpx.HTTPStatusError as exc:
+ return {
+ "type": "rpc.response",
+ "id": correlation_id,
+ "session": {"id": session_ctx["sessionKey"], "mode": "isolated"},
+ "error": {"code": "bridge_error", "message": f"Bridge returned {exc.response.status_code}"},
+ }
+ except httpx.RequestError as exc:
+ return {
+ "type": "rpc.response",
+ "id": correlation_id,
+ "session": {"id": session_ctx["sessionKey"], "mode": "isolated"},
+ "error": {"code": "bridge_unavailable", "message": str(exc)},
+ }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@integrations/openclaw/openclaw_gateway_adapter.py` around lines 335 - 349,
The except block after calling self._call_neurorift only handles PermissionError
and ValueError; add handlers for httpx.RequestError and httpx.HTTPStatusError to
prevent unhandled network/upstream failures from crashing the handler. Import
httpx, catch httpx.RequestError to return an RPC response with the same
"type"/"id"/"session" structure and an "error" like
{"code":"network_error","message":str(exc)} and catch httpx.HTTPStatusError to
return {"code":"upstream_error","message":str(exc)} (or similar mapping),
ensuring you reuse correlation_id and session_ctx["sessionKey"] as in the
existing handlers so all fields remain consistent.
Originally posted by @coderabbitai in #27 (comment)
Error handling catches
PermissionErrorandValueErrorbut nothttpxexceptions.If
_call_neuroriftfails with network errors (e.g.,httpx.RequestError,httpx.HTTPStatusError), they propagate uncaught, potentially crashing the message handler.Add httpx exception handling
except ValueError as exc: return { "type": "rpc.response", "id": correlation_id, "session": {"id": session_ctx["sessionKey"], "mode": "isolated"}, "error": {"code": "invalid_request", "message": str(exc)}, } + except httpx.HTTPStatusError as exc: + return { + "type": "rpc.response", + "id": correlation_id, + "session": {"id": session_ctx["sessionKey"], "mode": "isolated"}, + "error": {"code": "bridge_error", "message": f"Bridge returned {exc.response.status_code}"}, + } + except httpx.RequestError as exc: + return { + "type": "rpc.response", + "id": correlation_id, + "session": {"id": session_ctx["sessionKey"], "mode": "isolated"}, + "error": {"code": "bridge_unavailable", "message": str(exc)}, + }🤖 Prompt for AI Agents
Originally posted by @coderabbitai in #27 (comment)