fix(sourcemaps): Fix double association bug#2764
Merged
szokeasaurusrex merged 6 commits intomasterfrom Oct 9, 2025
Merged
Conversation
a1ca2bd to
7e16121
Compare
Fixes a bug where the same sourcemap can be associated with mulitple source files. Fixes #2445 Fixes [CLI-5](https://linear.app/getsentry/issue/CLI-5/ensure-collect-sourcemap-references-does-not-associate-the-same)
7e16121 to
6fc0961
Compare
lcian
approved these changes
Sep 30, 2025
Member
lcian
left a comment
There was a problem hiding this comment.
The high level idea and implementation look good to me after carefully reading through the code.
I would suggest simplifying the code to prioritize ease of understanding. It's easy to lose track when there's a lot of nesting like this.
Maybe some of the processing logic can be extracted into functions.
If this is not possible/beneficial, we could at least add comments to the for_each/fold/filter steps where the body is multiple lines, to make it easier to reason about specific steps in isolation.
Member
Author
|
Converting to draft while I work on the simplification, per @lcian's request |
Member
Author
|
@lcian is this good now? |
lcian
approved these changes
Oct 6, 2025
Member
lcian
left a comment
There was a problem hiding this comment.
Looks good and much easier to understand, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug where the same sourcemap can be associated with mulitple source files.
Change description
We solve this problem by keeping track of the sourcemaps we have already associated with a source file. If we guess a sourcemap which has already been associated, we do not associate the given source file with any sourcemap.
Also, we iterate first through all the sources which explicitly reference the sourcemap – i.e., for which, we don't have to guess the sourcemap. These are associated first. As they are explicitly linked to a sourcemap, we intentionally do not prevent duplicates here.
On the second iteration, we guess the sourcemap reference for all remaining sources. We enforce the no duplicates rule on the second iteration. Sources cannot be associated with a sourcemap that was explicitly referenced by another source on the first iteration. If multiple sources guess the same sourcemap, and that sourcemap is not explicitly associated with any source, then none of the sources will be associated with that sourcemap (as it is unclear how that sourcemap should be associated).
In all cases, we warn the users that we failed to associate the sources properly.
Issues
Fixes #2445
Fixes CLI-5