Skip to content

Consolidate the two cookie parsers parseCookie and parseCookieHeader #24501

Description

@s1gr1d

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-Cookie attributes: filterCookies('sid=1; Max-Age=3600; Path=/', true) returns {sid: '[Filtered]', 'Max-Age': '3600', Path: '/'}. Max-Age and Path are metadata, not cookies. parseCookieHeader strips them.
  • Only parseCookie URL-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: #24090 (comment) and #24090 (comment).

Activity

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

Metadata

Metadata

Assignees

Labels

javascriptPull requests that update javascript code

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions