Skip to content

SDK throwing URIError URI malformed in some cases #19391

@rodolfoBee

Description

@rodolfoBee

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react-router

SDK Version

10.22.0

Framework Version

NA

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

Exact steps to reproduce are currently unclear

Expected Result

No errors sent by the SDK

Actual Result

Error as seen in Sentry:

URIError: URI malformed
    at decodeURI (<anonymous>)
    at ? (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/utils/node-stack-trace.js:99:30)
    at ? (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/utils/stacktrace.js:42:23)
    at parseStackFrames (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/utils/eventbuilder.js:10:10)
    at exceptionFromError (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/utils/eventbuilder.js:22:18)
    at eventFromUnknownInput (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/utils/eventbuilder.js:138:16)
    at NodeClient.eventFromException (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/server-runtime-client.js:33:19)
    at NodeClient.captureException (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/client.js:222:12)
    at NodeClient.captureException (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/server-runtime-client.js:57:18)
    at Scope.captureException (/var/task/node_modules/.pnpm/@sentry+core@10.22.0/node_modules/@sentry/core/build/esm/scope.js:504:18)

The stack trace points to this line:

return{ 
filename: filename ? decodeURI(filename) : undefined,
...

The exact cause of the error is unclear, but as pointed out by the affected user, a try/catch is used in another section as the decodeURI function can fail:

  try {
    newUrl = decodeURI(url);
  } catch {
    //Sometimes this breaks
  }

A possible solution is to wrap it in a try/catch block.

Link to internal ticket

Additional Context

No response

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions