Skip to content

_⚠️ Potential issue_ | _🟠 Major_ #31

@Neuro-Rift

Description

@Neuro-Rift

⚠️ 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions