Skip to content

Fix SSE client error handling and propagate API key in headers#103

Merged
jfrench9 merged 1 commit intomainfrom
bugfix/sse-client-bug
Apr 25, 2026
Merged

Fix SSE client error handling and propagate API key in headers#103
jfrench9 merged 1 commit intomainfrom
bugfix/sse-client-bug

Conversation

@jfrench9
Copy link
Copy Markdown
Member

Summary

This PR fixes bugs in the SSE client related to error handling and API key propagation. The SSE client was not properly handling error scenarios, and the API key was not being passed through in request headers, causing authentication failures during server-sent event connections.

Key Accomplishments

  • Enhanced SSE client error handling: Added robust error handling logic to the SSE client to gracefully manage connection failures, malformed responses, and other error conditions during event streaming.
  • API key header propagation: Fixed a bug where the API key was not being included in headers when establishing SSE connections through the operation client, ensuring authenticated access to event streams.
  • Model correction: Updated the CreateEventHandlerRequest model to fix a field type/definition issue.
  • Test coverage: Added comprehensive unit tests for the SSE client to validate error handling behavior and ensure regressions are caught.

Changes Breakdown

File Change
operation_client.py Extended with API key header propagation and improved SSE connection setup (~35 lines added)
sse_client.py Added error handling logic for SSE stream consumption (~26 lines added)
create_event_handler_request.py Minor model field fix
test_sse_client.py New test cases for SSE client error scenarios (~35 lines added)

Breaking Changes

None. These changes are backward-compatible fixes that improve reliability without altering the public API surface.

Testing Notes

  • New unit tests have been added in test_sse_client.py covering error handling paths in the SSE client.
  • Verify that SSE connections properly authenticate using the API key in environments where authentication is required.
  • Test SSE reconnection and error recovery scenarios in integration/staging environments to confirm graceful degradation under network instability.

Infrastructure Considerations

  • Ensure that any API gateway or proxy configurations allow the API key header to pass through on SSE/long-lived HTTP connections.
  • Monitor SSE connection error rates after deployment to validate the improved error handling reduces silent failures.

🤖 Generated with Claude Code

Branch Info:

  • Source: bugfix/sse-client-bug
  • Target: main
  • Type: bugfix

Co-Authored-By: Claude noreply@anthropic.com

@jfrench9 jfrench9 merged commit 4a7ebb3 into main Apr 25, 2026
1 check passed
@jfrench9 jfrench9 deleted the bugfix/sse-client-bug branch April 25, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant