Skip to content

fix(apollo5): Handle beforeSpan callback failures - #6238

Merged
adinauer merged 3 commits into
fix/callback-error-handlingfrom
fix/callback-error-handling-apollo-5
Oct 9, 2026
Merged

adinauer merged 3 commits into
fix/callback-error-handlingfrom
fix/callback-error-handling-apollo-5

Conversation

@adinauer

@adinauer adinauer commented Oct 9, 2026

Copy link
Copy Markdown
Member

📜 Description

Handle exceptions from Apollo 5 beforeSpan callbacks without disrupting the GraphQL request. Failed sampled spans are dropped and recorded as callback_error; unsampled spans are dropped without reporting a loss.

💡 Motivation and Context

The Apollo 3 and Apollo 4 integrations already isolate this callback. Apollo 5 logged the exception but left the partially modified span sampled, so it could still be captured and client reports did not reflect the callback failure.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry-apollo-5:test

📝 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

None.

adinauer and others added 2 commits October 9, 2026 06:24
Drop spans when the Apollo 5 beforeSpan callback throws while preserving the GraphQL response. Report sampled spans as callback errors so client reports and discard callbacks remain accurate.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@@ -207,6 +210,13 @@ constructor(
}
} catch (e: Throwable) {
ExceptionUtils.rethrowIfFatal(e)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would need to be backported to Apollo3 and 4, correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's already in place in this PR stack. Apollo 5 was missing because it was merged recently.

@lbloder lbloder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@adinauer
adinauer marked this pull request as ready for review October 9, 2026 09:04
@adinauer
adinauer merged commit db0ed76 into fix/callback-error-handling Oct 9, 2026
64 of 66 checks passed
@adinauer
adinauer deleted the fix/callback-error-handling-apollo-5 branch October 9, 2026 09:04
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- Handle beforeSpan callback failures ([#6238](https://github.com/getsentry/sentry-java/pull/6238))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 77b9784

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.

2 participants