Skip to content

fix: three defensive bug fixes (DSN cache poisoning, region silent catches, projects silent catches) - #1433

Closed
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/sentry-cli-bug-fixes-d99d
Closed

cursor[bot] wants to merge 3 commits into
mainfrom
cursor/sentry-cli-bug-fixes-d99d

Conversation

@cursor

@cursor cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Three independent bug fixes found via codebase analysis. Each addresses a different class of silent failure that made debugging CLI issues difficult.


Fix 1: dsn-cache.ts — Empty DSN cache poisoning

Root cause: When setCachedDetection() is called with an empty allDsns array (no DSNs found), it stores dsn="" and project_id="" in the dsn_cache table. getCachedDsn() then returned these entries as valid cache hits.

Reproduction: Run any CLI command in a project with no Sentry DSN configured. The empty row gets stored, then subsequent detectDsn() calls waste time verifying a bogus cache entry before falling through to full scan.

Fix: Guard getCachedDsn() to return undefined when dsn is empty.


Fix 2: region.ts — Silent catches in resolveEffectiveOrg

Root cause: Two catch blocks silently swallowed errors from resolveOrgRegion() and listOrganizationsUncached(), making org resolution failures invisible in debug output.

Reproduction: Org resolution fails due to network error or auth issue — user sees the raw slug used as fallback with no explanation of why resolution failed.

Fix: Add log.debug() calls so errors are visible with --verbose.


Fix 3: api/projects.ts — Silent catches in project operations

Root cause: Multiple catch blocks in listProjects, seedProjectCaches, findProjectByDsnKey, and tryGetPrimaryDsn silently swallowed errors, making it impossible to diagnose why DSN detection, project resolution, or shell completions were not working.

Reproduction: Any of these best-effort operations fail (e.g., cache write error, network timeout in region fan-out) — user gets no diagnostic output.

Fix: Add log.debug() calls to all silent catch blocks.

Open in Web View Automation 

cursoragent and others added 3 commits August 17, 2026 12:08
When setCachedDetection() is called with an empty allDsns array (no DSNs
found during detection), it writes dsn="" and project_id="" into the
dsn_cache table. getCachedDsn() previously returned these entries as valid
cache hits, causing downstream code to receive a CachedDsnEntry with an
empty DSN string. This wastes time on verification attempts and inflates
cache hit telemetry with bogus entries.

Guard getCachedDsn() to return undefined (cache miss) when the stored DSN
is empty, so the caller falls through to a fresh detection scan.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
The two catch blocks in resolveEffectiveOrg() silently swallowed errors from
resolveOrgRegion() and listOrganizationsUncached(), making it impossible to
diagnose why org resolution fell back to the raw slug. Network errors, auth
issues, and API failures were completely invisible in debug output.

Add log.debug() calls so errors are visible with --verbose, following the
project's catch-block logging standard.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
…rations

Multiple catch blocks in api/projects.ts silently swallowed errors:
- listProjects: cache population failures invisible
- seedProjectCaches: project/DSN cache seeding failures invisible
- findProjectByDsnKey: per-region lookup failures invisible
- tryGetPrimaryDsn: DSN key fetch failures invisible

All of these are best-effort operations that correctly fall back on error,
but the silent catches made it impossible to diagnose why DSN detection,
project resolution, or shell completions were not working. Add log.debug()
calls so errors are visible with --verbose.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
@vercel

vercel Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 17, 2026 12:12pm

Request Review

@github-actions github-actions Bot added the risk: low PR risk score: low label Sep 21, 2026
betegon added a commit that referenced this pull request Sep 22, 2026
## Summary

Swallowed best-effort failures (project cache writes, DSN key fan-out,
`tryGetPrimaryDsn`) were either silent or only visible with `--verbose`.
Users never pass that, so those errors never showed up as Sentry issues.

Those catches now go through `reportCliError`: unexpected failures
become issues, and network/auth/4xx still get silenced. Org-resolution
fallbacks in `resolveEffectiveOrg` still only `log.debug`, because the
command-boundary error is already reported.

Also treats empty `dsn_cache` rows (`dsn=""` from a scan that found
nothing) as misses on the single-DSN path, so `detectDsn()` doesn't
verify a poisoned cache hit.

Alternative to #1433, which only added debug logs.

## Test plan

- [x] `pnpm exec vitest run test/lib/db/dsn-cache.test.ts
test/lib/api/projects.test.ts test/lib/api-client.coverage.test.ts
test/lib/api-client.multiregion.test.ts
test/lib/resolve-effective-org.test.ts`
- [ ] A 500 from `tryGetPrimaryDsn` shows up as a Sentry issue; a 404
does not
- [ ] `detectDsn()` in a repo with no DSN does not treat an empty cache
row as a hit


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@betegon

betegon commented Sep 22, 2026

Copy link
Copy Markdown
Member

fixed these things correctly on #1623

@betegon betegon closed this Sep 22, 2026

This branch was successfully deployed

1 active deployment
Preview — 79e65324 Deployed Aug 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants