Skip to content

fix(apollo): Skip failed-request body inspection for streaming responses - #6432

Draft
lbloder wants to merge 2 commits into
mainfrom
fix/apollo-multipart-response-inspection-main
Draft

lbloder wants to merge 2 commits into
mainfrom
fix/apollo-multipart-response-inspection-main

Conversation

@lbloder

@lbloder lbloder commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

📜 Description

The Apollo 3 and 4 integrations no longer inspect the response body of streaming responses (multipart/mixed, text/event-stream) for GraphQL errors, and they now check failedRequestTargets before reading the body at all.

Previously, failed-request detection peeked at the entire response body (response.body?.peek()?.readUtf8()) before the interceptor returned the response. For multipart responses used by @defer / @stream (and multipart subscriptions), that read waits for the end of the stream, so incremental delivery stalls until the whole response has arrived, or indefinitely for unbounded streams.

This ports the behavior the Apollo 5 integration already has since #6074 (SentryApollo5HttpInterceptor.isStreamingResponse). Spans and breadcrumbs are still recorded for streaming responses; they are written in finish(), which does not read the body.

Per the decision on the issue, there is no option to re-enable inspection for multipart responses. GraphQL errors delivered inside multipart parts are therefore not reported as failed requests.

Apollo 3 is not listed in the issue, but Apollo Kotlin 3.x also supports @defer over multipart and had the same code path, so it is included.

💡 Motivation and Context

Adding Sentry to an Apollo client breaks @defer / @stream.

💚 How did you test it?

Ported the Apollo 5 tests to Apollo 3 and 4. Each test calls the interceptor directly with a response body that records whether it was read:

  • body not read when the failed-request target does not match
  • body not read and no event captured for multipart/mixed and text/event-stream (case- and parameter-insensitive)
  • body read and event captured for application/json and for responses without a content type

The three "not read" tests failed before the fix. The fixture uses a non-empty errors array.

./gradlew :sentry-apollo-3:check :sentry-apollo-4:check :sentry-apollo-5:check

Added google-truth as a test dependency to sentry-apollo-3 and sentry-apollo-4.

Targets main so 8.x users get the fix; it reaches 9.x.x via the regular main → 9.x.x sync.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Apollo 3 and 4 peeked at the full response body to detect GraphQL errors
before returning the response. For multipart (@defer/@stream) and
server-sent event responses, that read waits for the end of the stream,
breaking incremental delivery.

Skip body inspection for multipart/mixed and text/event-stream responses,
and check failedRequestTargets before reading the body. This matches the
Apollo 5 integration. Spans and breadcrumbs are still recorded.

Fixes #5987

(cherry picked from commit dceacfe)
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

JAVA-703

@sentry

sentry Bot commented Oct 30, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.62.0 (1) release

⚙️ sentry-android Build Distribution Settings

@lbloder

lbloder commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@sentry review

@lbloder

lbloder commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e2233df. Configure here.

This branch has not been deployed

No deployments
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.

Handle Apollo multipart failed-request inspection safely

1 participant