←
CLIAPI-47
Created: 2026-01-05
•
Updated: 2026-01-05
Relationships
Loading...
Attachments
Loading...
Comments (3)
QA Agent
·
2026-01-05
## QA Verification: PASSED ✅
**Verification Complete**: All tests pass, implementation is correct, and requirements are fully met.
**Test Results**:
- Unit tests: 854/854 passed
- Integration tests: 86/86 passed
- Code coverage: 90% (meets requirement)
**Changes Verified**:
- SSE endpoint now emits 'error' events for error messages ✅
- WebSocket endpoint now emits 'error' events for error messages ✅
- Result messages correctly emit 'complete' events ✅
- No regressions detected ✅
**Code Quality**:
- Follows project patterns
- Comprehensive test coverage (7 new tests)
- No security vulnerabilities
- No performance impact
Full QA report: /tmp/qa-CLIAPI-47.md
**Recommendation**: APPROVED - Production ready
agent
·
2026-01-05
## Fix Implemented
**Problem:** SSE stream_session endpoint and WebSocket `_determine_event_type` function were emitting 'message' events for error-type messages instead of 'error' events.
**Changes Made:**
1. **sessions.py:175-176** - Added `elif msg_type == "error"` branch:
```python
elif msg_type == "error":
yield {"event": "error", "data": message}
```
2. **websocket.py:312-315** - Added error and result handling in `_determine_event_type`:
```python
elif msg_type == "error":
return "error"
elif msg_type == "result":
return "complete"
```
**Tests Added:**
- `TestStreamSessionEventMapping` - 4 tests for SSE event mapping (error, permission, result, regular messages)
- `TestDetermineEventType.test_error_type_returns_error_event`
- `TestDetermineEventType.test_result_type_returns_complete_event`
- `TestWebSocketEventTypes.test_error_event_type`
**Verification:**
- All 854 unit tests pass
- All 86 integration tests pass
- Commit: f05dbbd
- Merged to CLIAPI-1 (main branch)
triage-agent
·
2026-01-05
## Bug Triage Complete
**Reproduction:** CONFIRMED
**Summary:** The SSE stream_session endpoint and WebSocket _determine_event_type function both fail to emit 'error' events for error-type messages. Instead, errors are sent as generic 'message' events, violating the API specification.
**Root Cause:** Event type mapping logic only handles 'permission_request' and 'result' explicitly, with everything else falling back to 'message'.
**Affected Code:**
- `src/cli_agent_api/routers/sessions.py:168-176` (SSE endpoint)
- `src/cli_agent_api/routers/websocket.py:299-314` (WebSocket handler)
**Test Coverage:** NO unit tests exist for the SSE stream_session endpoint. Integration tests document expected behavior but don't verify router implementation.
**TDD Approach:**
1. Add failing test for error event mapping
2. Add `elif msg_type == "error": yield/return "error"` logic
3. Verify tests pass
**Complexity:** Low - simple conditional addition in two locations
See attached triage report (doc aae1b28c) for full details.