fix: send complete Accept header in SSE client - #848
Open
SomSamantray wants to merge 4 commits into
Open
Conversation
connect_sse and aconnect_sse hardcoded Accept: text/event-stream, which 406s servers that require application/json in the Accept header (e.g. Composio MCP, issue elevenlabs#671). Send both media types, retaining text/event-stream for strict SSE servers.
Mirror the sync coverage for aconnect_sse: SSEError on non-SSE content-type and preservation of caller-supplied headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SSE connections from
connect_sseandaconnect_ssenow sendAccept: application/json, text/event-streaminstead ofAccept: text/event-stream. Servers that validate the Accept header (e.g. Composio MCP, issue #671) previously rejected the request with 406.text/event-streamis retained, so strict SSE servers keep working.The hand-edited Fern-generated module is protected from regeneration via
.fernignore, and regression tests cover the sync and async paths, header preservation, and the response content-type guard.Fixes #671
Test plan
pytest tests/test_http_sse.py- 6 new tests pass.ELEVENLABS_API_KEY(CI provides it).ruffandmypyclean on changed files.Session-settled decisions carried from planning: the combined Accept header value (user-approved); no Compound Engineering branding on this PR (user-directed).
Note
Low Risk
Narrow HTTP client header change with existing content-type validation; residual risk of strict servers preferring JSON is documented separately (#847).
Overview
Fixes 406 rejections from gateways that require
Acceptto includeapplication/json(e.g. Composio MCP, #671) by changingconnect_sseandaconnect_sseto sendAccept: application/json, text/event-streaminstead of onlytext/event-stream.src/elevenlabs/core/http_sse/is added to.fernignoreso this hand-edited module is not overwritten on Fern regen.tests/test_http_sse.pyadds six regression tests (sync/async Accept value, custom header preservation, andSSEErrorwhen the response is nottext/event-stream).Reviewed by Cursor Bugbot for commit ab802db. Bugbot is set up for automated code reviews on this repo. Configure here.