Skip to content

[Android] [SentryHttpClientException] Exclusions #3244

Closed

Description

@barry-irvine

Integration

sentry-android-okhttp

Build System

Gradle

AGP Version

8.2.2

Proguard

Enabled

Version

7.4.0

Steps to Reproduce

I'm getting a number of 504 errors from https://res.cloudinary.com that I want to suppress. I am trying to suppress the error results from this domain when I add the Sentry interceptor. E.g.

  OkHttpClient.Builder().addInterceptor(SentryOkHttpInterceptor(failedRequestTargets = 
    listOf("^(?!(.*.cloudinary.com))"))).build()

Am I defining the regex incorrectly? I can't find any decent documentation on this.

Expected Result

No errors are returned for given domain name.

Actual Result

Sentry console filled with SentryHttpClientException: HTTP Client Error with status code: 504 for this domain.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 5, 2024
  2. markushi commented on Mar 6, 2024

    @markushi
    Member

    Hi @barry-irvine, thanks for reaching out!

    failedRequestTargets can either be a plain string or an regex. But there's no need to define regex groups aka (). So in your case this should work fine:

    My bad, I misunderstood your question. The regex supplied in failedRequestTargets needs to match a full URL, including the scheme and potential url parameters. Something like this should work:

    OkHttpClient.Builder().addInterceptor(
        SentryOkHttpInterceptor(failedRequestTargets = listOf("^((http|https)://)?(?!.*\.?cloudinary\.com).*$"))
    ).build()
  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Mar 6, 2024
  4. moved this to Waiting for: Community in GitHub Issues with 👀 2on Mar 6, 2024
  5. moved this from Waiting for: Community to No status in GitHub Issues with 👀 2on Mar 6, 2024
  6. moved this to Waiting for: Community in GitHub Issues with 👀 2on Mar 13, 2024
  7. 15 remaining items

  8. moved this to Waiting for: Community in GitHub Issues with 👀 2on Mar 22, 2024
  9. romtsn commented on Mar 27, 2024

    @romtsn
    Contributor

    @barry-irvine did you manage to verify whether the updated answer works for your case?

  10. courville commented on Mar 27, 2024

    @courville

    @courville thanks for chiming in here, do you have failedRequestTargets configured in your app?

    This behavior is likely due to changes introduced in 7.1.0(see changelog), where the SDK would start reporting errors, which it previously didn't.

    thanks for the feedback and nova-video-player/aos-Video@930b65b did the trick.

    This was quite a change of behavior and unexpected.

    Sorry for the noise.

  11. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 27, 2024
  12. kahest commented on Mar 28, 2024

    @kahest
    Contributor

    @courville Apologies for the confusion - 7.1.0 fixed an issue where before that versoin, errors wouldn't be reported even though we communicated that they would. In general we don't change behavior like this outside of major version bumps.

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Mar 28, 2024
  14. markushi commented on Apr 3, 2024

    @markushi
    Member

    Closing this for now, if you think there's still an issue simply re-open this ticket.

  15. barry-irvine commented on Apr 15, 2024

    @barry-irvine
    Author

    @markushi I've finally got the updated code in production and can still see the 504 cloudinary errors in Sentry.

    This was the final implementation. Did I do something wrong?

    @Provides
    @CommonOkHttp
    fun provideCommonOkHttpClient(): OkHttpClient =
        OkHttpClient.Builder()
            .addInterceptor(
                SentryOkHttpInterceptor(failedRequestTargets = listOf("^((http|https)://)?(?!.*\\.?cloudinary\\.com).*$"))
            ).build()
    

    And yet I see a 504 error for "https://res.cloudinary.com/dtljonz0f/image/upload/c_fill,g_auto,h_333,w_250/gc-v1/las-vegas/Favorite-Bistro7206_0.jpg" in the console. It looks like we get the 504s when the user's device is offline and Coil (the library we use for image processing) doesn't even bother to send the image request to Cloudinary because it knows they're offline so it just returns a 504 straightaway.

  16. angusholder commented on Apr 23, 2026

    @angusholder
    Contributor

    @markushi I've finally got the updated code in production and can still see the 504 cloudinary errors in Sentry.

    This was the final implementation. Did I do something wrong?

    @Provides
    @CommonOkHttp
    fun provideCommonOkHttpClient(): OkHttpClient =
        OkHttpClient.Builder()
            .addInterceptor(
                SentryOkHttpInterceptor(failedRequestTargets = listOf("^((http|https)://)?(?!.*\\.?cloudinary\\.com).*$"))
            ).build()
    

    And yet I see a 504 error for "https://res.cloudinary.com/dtljonz0f/image/upload/c_fill,g_auto,h_333,w_250/gc-v1/las-vegas/Favorite-Bistro7206_0.jpg" in the console. It looks like we get the 504s when the user's device is offline and Coil (the library we use for image processing) doesn't even bother to send the image request to Cloudinary because it knows they're offline so it just returns a 504 straightaway.

    For anyone who was having this issue of non-existent 504s being reported to Sentry, it was just fixed in 8.40.0 here: #5299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugIssue type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions