Skip to content

Commit 117465e

Browse files
alimoradi296claude
andcommitted
Complete remaining cubic-dev-ai fixes
Addresses the last three cubic-dev-ai suggestions that weren't auto-fixed: 1. Fix peername guard in websocket_server.py: - Check if peername exists and has length before indexing - Prevents crash when transport lacks peer data 2. Fix CLAUDE.md test paths: - Update from non-existent tests/client paths - Point to actual plugin test directories 3. Fix JSON-RPC example in README.md: - Update example to show actual output (stringified params) - Add note explaining the behavior All WebSocket tests passing (9/9). Ready for PR merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 08dd85d commit 117465e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pytest
3131
# Run tests with coverage
3232
pytest --cov=src/utcp
3333

34-
# Run specific test files
35-
pytest tests/client/test_openapi_converter.py
36-
pytest tests/client/transport_interfaces/test_http_transport.py
34+
# Run specific plugin tests
35+
pytest plugins/communication_protocols/http/tests/
36+
pytest plugins/communication_protocols/websocket/tests/
3737
```
3838

3939
### Development Dependencies

example/src/websocket_example/websocket_server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ async def websocket_handler(self, request):
132132
ws = WebSocketResponse()
133133
await ws.prepare(request)
134134

135-
client_info = f"{request.remote}:{request.transport.get_extra_info('peername')[1] if request.transport else 'unknown'}"
135+
# Get client info safely
136+
peername = request.transport.get_extra_info('peername') if request.transport else None
137+
if peername and len(peername) > 1:
138+
client_info = f"{request.remote}:{peername[1]}"
139+
else:
140+
client_info = str(request.remote) if request.remote else 'unknown'
136141
self.logger.info(f"WebSocket connection from {client_info}")
137142

138143
# Log any authentication headers

plugins/communication_protocols/websocket/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ await client.call_tool("iot.control", {
289289
"response_format": "json"
290290
}
291291

292-
# Sends: {"jsonrpc": "2.0", "method": "getUser", "params": {"id": 123}, "id": 1}
292+
# Sends: {"jsonrpc": "2.0", "method": "getUser", "params": "{\"id\": 123}", "id": 1}
293+
# Note: params is stringified since it's a non-string value in the template
293294
result = await client.call_tool("jsonrpc.call", {
294295
"method": "getUser",
295296
"params": {"id": 123}

0 commit comments

Comments
 (0)