From 4f90ebca9b9a6ffffc08185a2d4e9ddc45f6e190 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 16:46:02 +0100 Subject: [PATCH 1/3] Skip the throw frame source line test on Android 2021.3 --- .github/workflows/test-run-android.yml | 1 + test/IntegrationTest/Integration.Tests.ps1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/test-run-android.yml b/.github/workflows/test-run-android.yml index 6400e761d..8d90dc546 100644 --- a/.github/workflows/test-run-android.yml +++ b/.github/workflows/test-run-android.yml @@ -32,6 +32,7 @@ jobs: HOMEBREW_NO_INSTALL_CLEANUP: 1 SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_TEST_UNITY_VERSION: ${{ inputs.unity-version }} steps: - name: Checkout diff --git a/test/IntegrationTest/Integration.Tests.ps1 b/test/IntegrationTest/Integration.Tests.ps1 index 6e9f39c20..9f39a191d 100644 --- a/test/IntegrationTest/Integration.Tests.ps1 +++ b/test/IntegrationTest/Integration.Tests.ps1 @@ -447,6 +447,10 @@ Describe "Unity $($env:SENTRY_TEST_PLATFORM) Integration Tests" { Set-ItResult -Skipped -Because "line numbers come from the IL2CPP mappings, which a Mono player does not produce" return } + if ($script:Platform -eq "Android" -and $script:TestSetup.UnityVersion -like "2021.3*") { + Set-ItResult -Skipped -Because "on the Android 2021.3 x86_64 emulator, IL2CPP intermittently reports no stack frames for the thrown exception, so the event carries only the throwing frame without a native address" + return + } $frame = $runEvent.exception.values[0].stacktrace.frames | Where-Object { $_.module -eq "IntegrationTester" -and $_.function -eq "ThrowException" } | From d8593fe3c6ed428748fdf051c2ffc89df36f6017 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 11:24:52 +0100 Subject: [PATCH 2/3] Respect FilterBadGatewayExceptions when initializing in code --- CHANGELOG.md | 6 ++++++ .../ScriptableSentryUnityOptions.cs | 5 ----- src/Sentry.Unity/SentryUnitySdk.cs | 5 +++++ test/Sentry.Unity.Tests/SentryUnityTests.cs | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252fc315b..abeabb78f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Setting `FilterBadGatewayExceptions` to `false` now takes effect when initializing the SDK in code with `SentrySdk.Init`. ([#PR](https://github.com/getsentry/sentry-unity/pull/PR)) + ## 4.12.0 ### Behavioral Changes diff --git a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs index 936d22a33..77bb40e31 100644 --- a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs +++ b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs @@ -358,11 +358,6 @@ internal SentryUnityOptions ToSentryUnityOptions( private void HandleExceptionFilter(SentryUnityOptions options) { - if (!options.FilterBadGatewayExceptions) - { - options.RemoveExceptionFilter(); - } - if (!FilterWebExceptions) { options.RemoveExceptionFilter(); diff --git a/src/Sentry.Unity/SentryUnitySdk.cs b/src/Sentry.Unity/SentryUnitySdk.cs index 1464120da..a7811c854 100644 --- a/src/Sentry.Unity/SentryUnitySdk.cs +++ b/src/Sentry.Unity/SentryUnitySdk.cs @@ -31,6 +31,11 @@ private SentryUnitySdk(SentryUnityOptions options) // Some integrations are controlled through a flag and opt-in. Adding these integrations late so we have equal // behaviour whether the options got created through the ScriptableObject or the SDK gets manually initialized AddIntegrations(options); + if (!options.FilterBadGatewayExceptions) + { + options.RemoveExceptionFilter(); + } + SetUpWindowsPlayerCaching(unitySdk, options); ConfigureUnsupportedPlatformFallbacks(options); diff --git a/test/Sentry.Unity.Tests/SentryUnityTests.cs b/test/Sentry.Unity.Tests/SentryUnityTests.cs index adad2abe7..d9706593c 100644 --- a/test/Sentry.Unity.Tests/SentryUnityTests.cs +++ b/test/Sentry.Unity.Tests/SentryUnityTests.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using Debug = UnityEngine.Debug; using Sentry.Extensibility; +using Sentry.Unity.Integrations; using Sentry.Unity.Tests.SharedClasses; using Sentry.Unity.Tests.Stubs; using UnityEngine; @@ -78,6 +80,22 @@ public void SentryUnity_OptionsValid_Initializes() Assert.IsTrue(SentrySdk.IsEnabled); } + [Test] + public void SentryUnity_FilterBadGatewayExceptionsDisabled_RemovesBadGatewayFilter() + { + var options = new SentryUnityOptions(application: new TestApplication()) + { + Dsn = SentryTests.TestDsn, + FilterBadGatewayExceptions = false + }; + + SentrySdk.Init(options); + + var exceptionFiltersPropertyInfo = typeof(SentryOptions).GetProperty("ExceptionFilters", BindingFlags.NonPublic | BindingFlags.Instance); + var filters = (List)exceptionFiltersPropertyInfo!.GetValue(options); + Assert.That(filters.OfType(), Is.Empty); + } + [Test] public void SentryUnity_OptionsInvalid_DoesNotInitialize() { From b9e8ae87958b3f41e5c44ca5ee01b25e1762c7e9 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 11:38:25 +0100 Subject: [PATCH 3/3] Add PR link to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abeabb78f..49155c08a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- Setting `FilterBadGatewayExceptions` to `false` now takes effect when initializing the SDK in code with `SentrySdk.Init`. ([#PR](https://github.com/getsentry/sentry-unity/pull/PR)) +- Setting `FilterBadGatewayExceptions` to `false` now takes effect when initializing the SDK in code with `SentrySdk.Init`. ([#2930](https://github.com/getsentry/sentry-unity/pull/2930)) ## 4.12.0