Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sourcemaps): don't attempt to treat remote URL as a local file path #1850

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

brettdh
Copy link
Contributor

@brettdh brettdh commented Nov 30, 2023

When a sourceMappingURL is a remote URL (e.g. static storage in an S3 bucket), sentry-cli sourcemaps inject was treating it like a normal file path, attempting to "normalize" it with the source path, and producing a bogus url such as path/to/source/dir/https://some-static-host.example.com/path/to/foo.js.map, which of course doesn't exist, and thus the sourcemap isn't found and doesn't have the debug id injected - even if it's sitting right there in the local directory, next to its corresponding bundled source file.

With this change, the sourcemap discovery step does not attempt to use the discovered sourcemap URL if it is a remote URL. Instead, it falls back to guessing the sourcemap location based on the source filename and its location.

I also changed a couple trycmd tests to remove the + before the timezone offset,
as it causes the tests to fail when the local timezone is west of UTC.

Fixes #1846.

Copy link
Contributor

@loewenheim loewenheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change!

src/utils/sourcemaps.rs Outdated Show resolved Hide resolved
When a sourceMappingURL is a remote URL (e.g. static storage in an S3 bucket),
`sentry-cli sourcemaps inject` was treating it like a normal file path, attempting
to "normalize" it with the source path, and producing a bogus url such as
`path/to/source/dir/https://some-static-host.example.com/path/to/foo.js.map`,
which of course doesn't exist, and thus the sourcemap isn't found and doesn't have
the debug id injected - even if it's sitting right there in the local directory,
next to its corresponding bundled source file.

With this change, the sourcemap discovery step does not attempt to use the
discovered sourcemap URL if it is a remote URL. Instead, it falls back to guessing
the sourcemap location based on the source filename and its location.

I also changed a couple trycmd tests to remove the `+` before the timezone offset,
as it causes the tests to fail when the local timezone is west of UTC.

Fixes getsentry#1846.
@brettdh
Copy link
Contributor Author

brettdh commented Nov 30, 2023

Added an integration test for a sourceMappingURL with a full, externally hosted URL.

@loewenheim loewenheim merged commit 38daba8 into getsentry:master Dec 1, 2023
12 checks passed
@loewenheim
Copy link
Contributor

Thank you very much for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fall back to co-located source maps in sourcemaps inject command
2 participants