fix(api): strip api/0/ prefix and exclude NodeSystemError integration (CLI-K1)#523
fix(api): strip api/0/ prefix and exclude NodeSystemError integration (CLI-K1)#523
Conversation
…CLI-K1) Two bugs caused CLI-K1: 1. normalizeEndpoint() did not strip api/0/ prefix when users included it in the endpoint argument (e.g. 'sentry api /api/0/projects/...'), producing doubled paths like /api/0/api/0/... 2. The Sentry SDK's NodeSystemError integration calls util.getSystemErrorMap() which Bun does not implement, crashing the SDK's event processing pipeline. Fix: strip api/0/ prefix in normalizeEndpoint(), exclude NodeSystemError from default integrations.
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. 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 92.86%. Project has 1076 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.79% 95.79% —%
==========================================
Files 185 185 —
Lines 25557 25569 +12
Branches 0 0 —
==========================================
+ Hits 24482 24493 +11
- Misses 1075 1076 +1
- Partials 0 0 —Generated by Codecov Action |
…e api/0?query - Emit log.warn when stripping the api/0/ prefix so users know it happened - Patch NodeSystemError integration with try-catch instead of excluding it, so system error context is still captured on runtimes that support it - Handle api/0?query edge case (query string without trailing slash) - Add tests for the api/0?query variant
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Try-catch won't catch errors from async processEvent
- Wrapped processEvent return value with Promise.resolve().catch() to handle both synchronous throws and asynchronous rejections from async functions.
Or push these changes by commenting:
@cursor push 1e12ec0a94
Preview (1e12ec0a94)
diff --git a/src/lib/telemetry.ts b/src/lib/telemetry.ts
--- a/src/lib/telemetry.ts
+++ b/src/lib/telemetry.ts
@@ -287,7 +287,9 @@
integration.processEvent = (...args) => {
try {
- return original(...args);
+ const result = original(...args);
+ // Handle both sync throws and async rejections
+ return Promise.resolve(result).catch(() => args[0]);
} catch {
// getSystemErrorMap is not available — skip enrichment, keep the event
return args[0];This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
…emErrorMap upfront - Remove api/0? query-string edge case (reviewer: clearly an error) - Replace try-catch patch with upfront hasGetSystemErrorMap check at module load — conditionally excludes NodeSystemError integration when util.getSystemErrorMap is missing (Bun)
- Move the api/0/ prefix warning from normalizeEndpoint (pure function) to the command's func() to avoid polluting stderr during unit tests - Remove api/0? query-string edge case per reviewer feedback - Replace try-catch SDK patch with upfront hasGetSystemErrorMap check at module load — excludes NodeSystemError when method is missing
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Replace duplicated api/0/ detection condition in func() with a length comparison against normalizeEndpoint's output. Since the function only adds at most 1 char (trailing slash), a shorter result indicates the prefix was stripped.


Fixes two bugs surfaced by CLI-K1:
1. Double
/api/0/prefix insentry apicommandWhen users include the
/api/0/prefix in the endpoint argument (e.g.sentry api /api/0/projects/my-org/my-project/environments/), the URL construction doubled it to/api/0/api/0/....normalizeEndpoint()now strips the prefix automatically.2.
util.getSystemErrorMap()crash on BunThe Sentry SDK's
NodeSystemErrorintegration callsutil.getSystemErrorMap()which Bun does not implement, causing the SDK's event processing pipeline to crash with a TypeError. This integration is now excluded from the default integrations set — it only adds extra context for Node.js system errors and is not needed for CLI telemetry.