Skip to content

fix(sentry-okhttp): Skip synthetic 504 for FORCE_CACHE cache misses#5299

Open
markushi wants to merge 2 commits intomainfrom
markushi/fix-okhttp-force-cache-504
Open

fix(sentry-okhttp): Skip synthetic 504 for FORCE_CACHE cache misses#5299
markushi wants to merge 2 commits intomainfrom
markushi/fix-okhttp-force-cache-504

Conversation

@markushi
Copy link
Copy Markdown
Member

📜 Description

OkHttp's CacheInterceptor synthesizes a 504 "Unsatisfiable Request" response when a request with only-if-cached (e.g. CacheControl.FORCE_CACHE) misses the cache. This is not a real server error, so we should not capture it as a failed request event.

This PR adds a check in SentryOkHttpInterceptor to skip reporting when the response is a 504 and the request has onlyIfCached set.

💡 Motivation and Context

💚 How did you test it?

  • Added unit test for synthetic 504 from FORCE_CACHE cache miss (verifies no event is captured)
  • Added unit test for real 504 without onlyIfCached (verifies event is still captured)
  • Ran full SentryOkHttpInterceptorTest suite — all tests pass

📝 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.

🔮 Next steps

OkHttp's CacheInterceptor synthesizes a 504 "Unsatisfiable Request"
response when a request with `only-if-cached` (e.g. CacheControl.FORCE_CACHE)
misses the cache. This is not a real server error, so don't capture it
as a failed request event.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (sentry-okhttp) Skip synthetic 504 for FORCE_CACHE cache misses by markushi in #5299

🤖 This preview updates automatically when you update the PR.

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 17, 2026

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

sentry-okhttp reports spurious 504 errors for CacheControl.FORCE_CACHE requests

1 participant