Skip to content

feat(init): cache project and DSN after create/init#730

Closed
betegon wants to merge 2 commits intomainfrom
feat/cache-project-on-create
Closed

feat(init): cache project and DSN after create/init#730
betegon wants to merge 2 commits intomainfrom
feat/cache-project-on-create

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 13, 2026

Summary

After sentry init or sentry project create, the resolved project and DSN data wasn't being saved to the local DB. This meant the next command (e.g. sentry issue list) had to re-scan files for the DSN and hit the API to resolve the project — even though all that info was just known.

This seeds the same caches that resolveFromDsn and detectDsn populate on their slow paths, so subsequent commands get cache hits instead.

Changes

  • createProjectWithDsn in projects.ts now caches in project_cache (by orgId:projectId and DSN public key). Covers both sentry init and sentry project create.
  • createSentryProject in local-ops.ts now caches in dsn_cache (keyed by directory) at both success paths — existing project reuse and new project creation.

All inline, matching the existing pattern in resolve-target.ts and detector.ts. Best-effort with try/catch so cache failures never break the command.

Test Plan

  • Run sentry project create acme/foo node → verify project_cache has entry
  • Run sentry init acme/my-app → verify both dsn_cache and project_cache populated
  • Run sentry issue list after init → resolves from cache, no extra API call
  • Dry-run paths return before caching code, so no writes happen
  • Existing tests pass (DB tests, project create tests)

createProjectWithDsn now seeds project_cache (by orgId:projectId and
DSN public key) so the next command resolves from cache instead of
hitting the API. Covers both `sentry init` and `sentry project create`.

sentry init additionally seeds dsn_cache (keyed by directory) at both
success paths (existing project + new project) so detectDsn() gets a
cache hit instead of re-scanning source files.

Follows the existing inline caching pattern used by resolveFromDsn and
detectDsn — no new abstractions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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 ✨

  • (cli) Add sentry cli defaults command for persistent settings by BYK in #721
  • (docs) Auto-generate driftable documentation sections by BYK in #739
  • (init) Cache project and DSN after create/init by betegon in #730
  • (issue-list) Add search syntax docs, case-insensitive AND/OR, and JSON syntax reference by BYK in #738
  • (trace) Consistent project filtering across trace commands (feat: support filtering spans by project within a trace #737) by BYK in #743
  • (trace-view) Expose span attributes in trace and span views by BYK in #742

Bug Fixes 🐛

Init

  • Treat no-op edits as passthrough instead of throwing by betegon in #731
  • Remove JSON minification that breaks edit-based codemods by betegon in #719

Resolve

  • Address review comments and add tests for fuzzy project recovery by BYK in #732
  • Fuzzy auto-recovery for project slug resolution by BYK in #728

Upgrade

  • Detect npm install method from node_modules path by BYK in #723
  • Add shell option on Windows for .cmd package managers by BYK in #722

Other

  • (ci) Add retry logic to ORAS/bsdiff downloads and upgrade ORAS by BYK in #741
  • (dashboard) Remove overly restrictive dataset-display cross-validation by BYK in #720
  • (errors) Improve ContextError wording for auto-detect failures by BYK in #726
  • (event-view) Add cross-org fallback when event not found by BYK in #744
  • (issue) Support share issue URLs by BYK in #718
  • (issue-list) Auto-correct AND and reject OR in --query to prevent 400 by BYK in #727
  • (telemetry) Rename isClientApiError to isUserApiError and exclude 400 by BYK in #729
  • Bug fixes from Sentry error monitoring (CLI-FR, CLI-RN) + auth default by BYK in #740

Internal Changes 🔧

  • Regenerate skill files by github-actions[bot] in ca16b2ff

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-730/

Built to branch gh-pages at 2026-04-14 08:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Codecov Results 📊

134 passed | Total: 134 | 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 1640 uncovered lines.
❌ Project coverage is 95.27%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.28%    95.27%    -0.01%
==========================================
  Files          234       234         —
  Lines        34644     34672       +28
  Branches         0         0         —
==========================================
+ Hits         33008     33032       +24
- Misses        1636      1640        +4
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon force-pushed the feat/cache-project-on-create branch 2 times, most recently from 8578f60 to be4d74d Compare April 13, 2026 14:30
The previous dsn_cache seeding in createSentryProject was broken:
- No sourcePath (DSN not yet written to files at that point)
- payload.cwd might not match projectRoot (detectDsn looks up by root)

Move the cache seeding to after handleFinalResult in runWizard. At that
point apply-patchset has already written the DSN to source files, so
detectDsn finds it and caches with the correct projectRoot and
sourcePath. The project_cache seeding in createProjectWithDsn (from the
prior commit) still handles the API-avoidance side.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@betegon betegon closed this Apr 14, 2026
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