Skip to content

Make tracePropagationTargets matching case-insensitive #16018

@Lms24

Description

@Lms24

Problem Statement

Currently, we have a bit of an obscure problem with tracePropagationTargets:

If users make a fetch request to a URL with casing (for whatever reason), they likely apply the same casing when defining tracePropagationTargets:

Sentry.init({
  tracePropagationTargets: ['myApi.com', /^myApi.com\/.*/]
})

fetch('https://myApi.com');

Unfortunately, the values in tracePropagationTargets counter-intuitively don't match because we create a new URL() from the URL passed to fetch when determining if our tracing headers should be attached.

The constructed URL object converts the entered url though to all-lower-case, meaning that when matching myapi.com against both, the string or the regex, we wouldn't get a positive match. Therefore, the currently correct way of specifying TPT for this URL would any one of :

Sentry.init({
  tracePropagationTargets: [
     'myapi.com', 
     /^myapi.com/,
     /^myApi.com/i,
]
})

Solution Brainstorm

For simplicity, we propose to convert all entries in tracePropagationTargets .toLower() and add a case insensitivity /i flag to RegExp values.

We're a bit worried though about subtly breaking existing setups that perhaps rely on case sensitivity. Therefore we consider this behaviour-breaking and opt to make the change in the next major.
(Also, intuitively, this sounds like a niche/edge case as it's rather uncommon to capitalize URLs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions