feat(code-mappings): Allow multiple source roots per stack root#111704
Merged
feat(code-mappings): Allow multiple source roots per stack root#111704
Conversation
Change the unique constraint on RepositoryProjectPathConfig from (project, stack_root) to (project, stack_root, source_root). This allows the same stack trace root to map to multiple source paths, which is needed for monorepos where the same package prefix exists in multiple modules (e.g. io/sentry/opentelemetry mapping to both sentry-opentelemetry-core and sentry-opentelemetry-bootstrap). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
This PR has a migration; here is the generated SQL for for --
-- Custom state/database change combination
--
CREATE UNIQUE INDEX CONCURRENTLY "sentry_repositoryproject_project_id_stack_root_so_c371dfa7_uniq" ON "sentry_repositoryprojectpathconfig" ("project_id", "stack_root", "source_root");
ALTER TABLE "sentry_repositoryprojectpathconfig" ADD CONSTRAINT "sentry_repositoryproject_project_id_stack_root_so_c371dfa7_uniq" UNIQUE USING INDEX "sentry_repositoryproject_project_id_stack_root_so_c371dfa7_uniq";
ALTER TABLE "sentry_repositoryprojectpathconfig" DROP CONSTRAINT "sentry_repositoryproject_project_id_stack_root_e376b891_uniq"; |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
… lookups Update auto-source-code-config callers to include source_root in their lookup keys, matching the new unique constraint on (project, stack_root, source_root). Without this, these calls would raise MultipleObjectsReturned once multiple mappings share the same stack_root. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Backend Test FailuresFailures on
|
…traint Update test_post_existing_code_mapping to assert both mappings coexist when stack_root matches but source_root differs, matching the new (project, stack_root, source_root) unique constraint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
armenzg
approved these changes
Mar 27, 2026
Member
armenzg
left a comment
There was a problem hiding this comment.
I really like this change.
We will see a huge uptick on code mappings for monorepos but I believe it will make a lot of things better.
wedamija
approved these changes
Mar 27, 2026
…ration Use SeparateDatabaseAndState to add the new unique constraint before removing the old one, avoiding a window without any unique constraint on the table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jan-auer
pushed a commit
that referenced
this pull request
Apr 1, 2026
) ## Summary - Change unique constraint on `RepositoryProjectPathConfig` from `(project, stack_root)` to `(project, stack_root, source_root)` - Update single-mapping serializer validation to include `source_root` in duplicate check - Update bulk endpoint upsert key to match on `(stack_root, source_root)` instead of just `stack_root` This allows the same stack trace root (e.g. `io/sentry/opentelemetry`) to map to multiple source paths in the repo (e.g. `sentry-opentelemetry-core/src/...` and `sentry-opentelemetry-bootstrap/src/...`), which is needed for monorepos with shared package prefixes across modules. Stack trace resolution already handles this correctly — it iterates all mappings sorted by specificity and uses the first match that resolves to a real file. ## Test plan - [x] All 63 existing tests pass (bulk + single endpoints) - [x] Updated tests to reflect new constraint semantics - [ ] Deploy migration and verify with real monorepo upload 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dashed
pushed a commit
that referenced
this pull request
Apr 1, 2026
) ## Summary - Change unique constraint on `RepositoryProjectPathConfig` from `(project, stack_root)` to `(project, stack_root, source_root)` - Update single-mapping serializer validation to include `source_root` in duplicate check - Update bulk endpoint upsert key to match on `(stack_root, source_root)` instead of just `stack_root` This allows the same stack trace root (e.g. `io/sentry/opentelemetry`) to map to multiple source paths in the repo (e.g. `sentry-opentelemetry-core/src/...` and `sentry-opentelemetry-bootstrap/src/...`), which is needed for monorepos with shared package prefixes across modules. Stack trace resolution already handles this correctly — it iterates all mappings sorted by specificity and uses the first match that resolves to a real file. ## Test plan - [x] All 63 existing tests pass (bulk + single endpoints) - [x] Updated tests to reflect new constraint semantics - [ ] Deploy migration and verify with real monorepo upload 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Summary
RepositoryProjectPathConfigfrom(project, stack_root)to(project, stack_root, source_root)source_rootin duplicate check(stack_root, source_root)instead of juststack_rootThis allows the same stack trace root (e.g.
io/sentry/opentelemetry) to map to multiple source paths in the repo (e.g.sentry-opentelemetry-core/src/...andsentry-opentelemetry-bootstrap/src/...), which is needed for monorepos with shared package prefixes across modules.Stack trace resolution already handles this correctly — it iterates all mappings sorted by specificity and uses the first match that resolves to a real file.
Test plan
🤖 Generated with Claude Code