Skip to content

fix(core): [Callback Errors 7] Handle replay sampling failures - #6165

Draft
adinauer wants to merge 2 commits into
fix/callback-error-handling-profiles-samplerfrom
fix/callback-error-handling-replay-sampling
Draft

adinauer wants to merge 2 commits into
fix/callback-error-handling-profiles-samplerfrom
fix/callback-error-handling-replay-sampling

Conversation

@adinauer

@adinauer adinauer commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Callback Errors)


📜 Description

Skip replay capture when beforeErrorSampling throws, while continuing to send the error event. Update the error log to reflect that replay capture is skipped.

Callbacks returning true or false, and configurations without a callback, retain their existing behavior. The existing catch type and reentrancy guard are unchanged; subsequent events can still trigger replay capture.

💡 Motivation and Context

A failed user replay filter must not trigger replay capture. Previously, throwing from beforeErrorSampling proceeded with capture, potentially sending replay data the callback intended to exclude.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:apiCheck :sentry:test --tests='*SentryClientTest*' --tests='*SentryClientInternalEventProcessorTest*' --tests='*SentryReplayOptionsTest*' — 276 tests passed
  • Both regression tests failed before the production fix because replay capture was invoked after callback failure.
  • Verify handled errors and crashes still reach the transport, replay capture is skipped, the failure is logged, and a subsequent successful callback can capture replay.

📝 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

Profile discard accounting and profile/replay artifact cleanup remain separate follow-ups. Callback-boundary catch-type changes remain deferred to the next major.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Skip replay capture when beforeErrorSampling throws instead of capturing
replay after a failed user filter. Continue sending the error event and
retain existing exception logging and catch types.

Cover handled errors, crashes, and successful replay capture after a
previous callback failure. Verify error delivery and failure logging.

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

sentry Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

Link the beforeErrorSampling failure entry to PR #6165.

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

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.

1 participant