Consolidate the two cookie parsers `parseCookie` and `parseCookieHeader`
Author: s1gr1dCreated Sep 18, 2026Updated Sep 18, 2026
Labelsjavascript
parseCookie (used by filterCookies for event cookie records) and parseCookieHeader (used by httpHeadersToSpanAttributes for span attributes) have several differences:
- Nameless segments:
filterCookies('opaque-blob; theme=dark', true)returns{theme: 'dark'}and drops the blob silently. The span attribute shows['[Filtered]', 'theme=dark']. Set-Cookieattributes:filterCookies('sid=1; Max-Age=3600; Path=/', true)returns{sid: '[Filtered]', 'Max-Age': '3600', Path: '/'}.Max-AgeandPathare metadata, not cookies.parseCookieHeaderstrips them.- Only
parseCookieURL-decodes values and strips quotes.
One parser returning ordered [name, value][] pairs, with a Set-Cookie mode, could work at both call sites. filterCookies.test.ts has two it.fails tests pinning the intended Set-Cookie behavior -> those need to be flipped when fixed.
Out of the #24090 review: https://github.com/getsentry/sentry-javascript/pull/24090#discussion_r4041421140 and https://github.com/getsentry/sentry-javascript/pull/24090#discussion_r4041448119.
Source: getsentry/sentry-javascript