perf(resolve): carry project data through resolution to eliminate redundant getProject calls#486
perf(resolve): carry project data through resolution to eliminate redundant getProject calls#486
Conversation
…undant getProject calls
resolveProjectBySlug() and resolveOrgProjectTarget() call findProjectsBySlug()
which internally fetches the full SentryProject via getProject() per org. But both
functions discarded that data, returning only { org, project } slugs. Callers that
needed the project ID or full details had to call getProject() a second time.
Changes:
- resolveProjectBySlug() now returns projectData alongside org/project slugs
- ResolvedOrgProject gains optional projectData for the project-search path
- ResolvedTarget gains optional projectData for downstream consumers
Fixed callers (each saves ~500-800ms in project-search path):
- dashboard/create.ts: use projectData.id instead of fetchProjectId()
- project/delete.ts: use projectData instead of re-calling getProject()
- project/view.ts: skip getProject() when projectData already available
Non-redundant callers (event/view, log/view, init, trace/span/log list) are
unchanged — they only need org/project slugs for scoping.
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1037 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.77% 95.77% —%
==========================================
Files 180 180 —
Lines 24507 24520 +13
Branches 0 0 —
==========================================
+ Hits 23470 23483 +13
- Misses 1037 1037 —
- Partials 0 0 —Generated by Codecov Action |
ProjectWithOrg (from findProjectsBySlug) carries an extra orgSlug field. When callers spread projectData into JSON output, this leaked an inconsistent field depending on the resolution path. Destructure out orgSlug before assigning to projectData so it's a clean SentryProject.
|
Good catch. Fixed in 22cf036 — both and |
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.
…rojectBySlug result Prevents unintended projectData from leaking into ResolvedEventTarget, consistent with the approach used in project/view.ts.
|
Fixed in be6735f — replaced |

Summary
resolveProjectBySlug()andresolveOrgProjectTarget()callfindProjectsBySlug()which fetches the fullSentryProjectviagetProject()per org — but both discard that data, returning only{ org, project }slugs. Three commands then callgetProject()a second time.This is the same class of redundancy that #473 fixed for the issue short-ID path, generalized to all project-search resolution consumers.
Changes
Core types (
src/lib/resolve-target.ts):resolveProjectBySlug()now returnsprojectData: SentryProjectalongside slugsResolvedOrgProjectgains optionalprojectData?(populated in project-search path)ResolvedTargetgains optionalprojectData?for downstream consumersFixed callers (each saves ~500-800ms in the project-search path):
dashboard/create.ts— usesprojectData.idinstead offetchProjectId()project/delete.ts— usesprojectDatainstead of re-callinggetProject()project/view.ts— skipsgetProject()whenprojectDataalready availableNon-redundant callers (
event/view,log/view,init,trace/span/log list) are unchanged — they only destructure{ org, project }for scoping.Test plan
bun run typecheckpassesbun run lintpassestoEqual→toMatchObjectwhere the newprojectDatafield is present