feat(config): support .sentryclirc config file for per-directory defaults#693
feat(config): support .sentryclirc config file for per-directory defaults#693
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 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 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 88.42%. Project has 1516 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.47% 95.38% -0.09%
==========================================
Files 224 227 +3
Lines 32534 32779 +245
Branches 0 0 —
==========================================
+ Hits 31059 31263 +204
- Misses 1475 1516 +41
- Partials 0 0 —Generated by Codecov Action |
7ca1150 to
e0b746c
Compare
e0b746c to
c0ef499
Compare
c0ef499 to
8d86cbd
Compare
465e9f9 to
519dc5f
Compare
c2f32be to
05d4dae
Compare
05d4dae to
e141d2f
Compare
448efc2 to
ae7499c
Compare
50670a8 to
9653462
Compare
0a10704 to
6148c3f
Compare
1b34396 to
3b880a9
Compare
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.
Reviewed by Cursor Bugbot for commit 3b880a9. Configure here.
| } | ||
|
|
||
| // Populate sentryclirc cache from accumulated data | ||
| setSentryCliRcCache(resolvedStart, rcConfig); |
There was a problem hiding this comment.
Cache overwrite drops global fallback config values
Medium Severity
walkUpDirectories accumulates .sentryclirc data via applySentryCliRcDir, which explicitly skips global paths (~/.sentryclirc, $SENTRY_CONFIG_DIR/.sentryclirc) because they're meant to be "applied as fallback after the walk." However, walkUpDirectories never calls applyGlobalFallbacks before calling setSentryCliRcCache, so the cached config is missing global fallback values. This overwrites any correctly-populated cache entry from a prior loadSentryCliRc call (which does call applyGlobalFallbacks in doLoad). The walk may also exit early (on DSN or repo root), further missing ancestor configs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3b880a9. Configure here.
3b880a9 to
496a257
Compare
…ults Add backward-compatible support for .sentryclirc INI config files. The CLI walks up from CWD to find config files, merging them (closest wins per-field) with ~/.sentryclirc as a global fallback. Supported fields: - [defaults] org, project, url - [auth] token Token and URL are applied via env shim (SENTRY_AUTH_TOKEN, SENTRY_URL). Org and project are inserted into the resolution chain between env vars and SQLite defaults with source tracking. This enables per-directory project defaults in monorepos and seamless migration from legacy sentry-cli.
496a257 to
dfe7a29
Compare
| state.levelsTraversed | ||
| ); | ||
| if (dsnResult && currentDir !== stopBoundary) { | ||
| setSentryCliRcCache(resolvedStart, rcConfig); |
There was a problem hiding this comment.
Bug: The .sentryclirc cache is populated prematurely by walkUpDirectories without global fallbacks, causing loadSentryCliRc to use an incomplete configuration.
Severity: HIGH
Suggested Fix
Delay populating the .sentryclirc cache until after all configuration sources, including global fallbacks, have been fully resolved and merged. Alternatively, ensure that loadSentryCliRc invalidates or ignores the incomplete cache entry created by walkUpDirectories and performs a complete configuration load.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/lib/dsn/project-root.ts#L487
Potential issue: The `.sentryclirc` configuration cache is prematurely populated by
`walkUpDirectories` with a configuration that omits global fallbacks, such as those from
`~/.sentryclirc`. Subsequent calls to `loadSentryCliRc` then access this incomplete
cache. This causes global settings like `auth.token` or `defaults.url` to be ignored,
which can lead to authentication or connection failures when the CLI attempts to
communicate with Sentry.


Summary
.sentryclircINI config file support, matching the legacysentry-cliformat~/.sentryclircas global fallbackSENTRY_AUTH_TOKEN,SENTRY_URL); org/project are inserted directly into the resolution chain with source trackingResolution chain (updated)
Monorepo example
New files
src/lib/ini.tssrc/lib/sentryclirc.tstest/lib/ini.test.tstest/lib/ini.property.test.tstest/lib/sentryclirc.test.tstest/lib/sentryclirc.property.test.tsModified files
src/cli.ts— callapplySentryCliRcEnvShim()early in bootsrc/lib/resolve-target.ts— insert step 3 in all 4 resolution functionsdocs/src/content/docs/configuration.md— new.sentryclircsection with monorepo guidedocs/src/content/docs/features.md— link to resolution priority + tipdocs/src/content/docs/agent-guidance.md— updated auto-detection referencesplugins/sentry-cli/skills/sentry-cli/SKILL.md— regenerated