From a9f45267ec874c456e1ab93d0b3303487936f50e Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 27 Nov 2026 12:52:04 +0100 Subject: [PATCH 1/2] fix(core): Omit empty cookie headers Return null when cookie-header filtering produces no values so request payloads omit the cookies field instead of serializing an empty string. Co-Authored-By: Claude --- .../main/java/io/sentry/util/CookieUtils.java | 2 +- .../java/io/sentry/util/CookieUtilsTest.kt | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sentry/src/main/java/io/sentry/util/CookieUtils.java b/sentry/src/main/java/io/sentry/util/CookieUtils.java index e50633a298..2af64b009c 100644 --- a/sentry/src/main/java/io/sentry/util/CookieUtils.java +++ b/sentry/src/main/java/io/sentry/util/CookieUtils.java @@ -55,7 +55,7 @@ public final class CookieUtils { filteredHeaders.add(filteredHeader); } } - return filteredHeaders; + return filteredHeaders.isEmpty() ? null : filteredHeaders; } public static @Nullable String filterCookies( diff --git a/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt b/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt index 183dec4a12..96bec1a4f4 100644 --- a/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt +++ b/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt @@ -306,6 +306,30 @@ class CookieUtilsTest { .isNull() } + @Test + fun `empty cookie header list returns null`() { + assertThat( + CookieUtils.filterCookiesFromHeader( + emptyList(), + KeyValueCollectionBehavior.denyList(), + emptyList(), + ), + ) + .isNull() + } + + @Test + fun `empty cookie header enumeration returns null`() { + assertThat( + CookieUtils.filterCookiesFromHeader( + java.util.Collections.enumeration(emptyList()), + KeyValueCollectionBehavior.denyList(), + emptyList(), + ), + ) + .isNull() + } + @Test fun `cookie header filter processes every header value`() { assertThat( From 589ca5e2c6ba79be08bd82484145dbc769f9af6a Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Fri, 27 Nov 2026 12:57:40 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6a6b69527..11b236df97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,6 +140,7 @@ ### Fixes +- Omit request cookies when no cookie headers are present ([#6799](https://github.com/getsentry/sentry-java/pull/6799)) - Set Apollo 3, 4, and 5 HTTP spans to `CANCELLED` instead of `INTERNAL_ERROR` when the request is cancelled ([#6284](https://github.com/getsentry/sentry-java/pull/6284)) - Preserve independent Netty read and write timeout events when exception singletons are reused. These exceptions now bypass event deduplication by default, so applications with multiple capture integrations may report the same timeout more than once. Use `SentryOptions.setIgnoredErrorsForDeduplication(...)` or `ignored-errors-for-deduplication` to customize or clear the default exclusions. ([#6465](https://github.com/getsentry/sentry-java/pull/6465)) - Prevent changes to reused tracing options from affecting spans and transactions after creation ([#6417](https://github.com/getsentry/sentry-java/pull/6417))