Skip to content

perf(resolve): carry project data through resolution to eliminate redundant getProject calls#486

Merged
BYK merged 3 commits intomainfrom
perf/resolve-project-data
Mar 19, 2026
Merged

perf(resolve): carry project data through resolution to eliminate redundant getProject calls#486
BYK merged 3 commits intomainfrom
perf/resolve-project-data

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 19, 2026

Summary

resolveProjectBySlug() and resolveOrgProjectTarget() call findProjectsBySlug() which fetches the full SentryProject via getProject() per org — but both discard that data, returning only { org, project } slugs. Three commands then call getProject() 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 returns projectData: SentryProject alongside slugs
  • ResolvedOrgProject gains optional projectData? (populated in project-search path)
  • ResolvedTarget gains optional projectData? for downstream consumers

Fixed callers (each saves ~500-800ms in the project-search path):

  • dashboard/create.ts — uses projectData.id instead of fetchProjectId()
  • project/delete.ts — uses projectData instead of re-calling getProject()
  • project/view.ts — skips getProject() when projectData already available

Non-redundant callers (event/view, log/view, init, trace/span/log list) are unchanged — they only destructure { org, project } for scoping.

Test plan

  • bun run typecheck passes
  • bun run lint passes
  • All affected test suites pass (298 tests across 12 files)
  • Tests updated: toEqualtoMatchObject where the new projectData field is present

…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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482
  • Dynamic cache-backed shell completions with fuzzy matching by BYK in #465

Bug Fixes 🐛

  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475
  • Add org-slug pre-check to dispatchOrgScopedList (CLI-9A) by BYK in #485

Internal Changes 🔧

  • (issue) Skip getProject round-trip in project-search resolution by betegon in #473
  • (resolve) Carry project data through resolution to eliminate redundant getProject calls by BYK in #486
  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1037 uncovered lines.
✅ Project coverage is 95.77%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
resolve-target.ts 82.89% ⚠️ 117 Missing
delete.ts 99.40% ⚠️ 1 Missing
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

@BYK BYK marked this pull request as ready for review March 19, 2026 22:54
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.
@BYK
Copy link
Copy Markdown
Member Author

BYK commented Mar 19, 2026

Good catch. Fixed in 22cf036 — both and resolveOrgProjectTarget() now destructure out orgSlug from the ProjectWithOrg before assigning to projectData, so it's a clean SentryProject and won't leak into JSON output when callers spread it.

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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.
@BYK
Copy link
Copy Markdown
Member Author

BYK commented Mar 19, 2026

Fixed in be6735f — replaced ...resolved spread with explicit field mapping in event/view.ts, consistent with how project/view.ts was handled.

@BYK BYK merged commit f8eb06b into main Mar 19, 2026
22 checks passed
@BYK BYK deleted the perf/resolve-project-data branch March 19, 2026 23:35
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.

1 participant