Skip to content

fix(cli): Silence dropped connections and bad sourcemap directories - #1606

Merged
BYK merged 1 commit into
mainfrom
fix/cli-silence-env-noise
Oct 23, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/cli-silence-env-noise

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Two kinds of user-environment failures still show up in Sentry as CLI issues:

  • TypeError: terminated (CLI-2AD): undici throws this when the connection drops while the response body is streaming. fix(cli): retry interrupted GET responses across commands #1548 already retries finite GET bodies, so one that still gets through is the same offline/proxy noise as fetch failed. isNetworkError() now matches it too.
  • Bad sourcemap directory (CLI-1FN): assertDirectoryReadable throws a ValidationError with field "directory" when the directory doesn't exist, isn't a directory, or can't be read. This is now silenced the same way as the missing --input file case (CLI-1JY).

The original getsentry/cli#1616 silenced every ValidationError and changed paginate() back to fixed page sizes. That conflicts with the targeted silencing policy here and with getsentry/cli#1615, so this port only covers the sourcemap directory case.

Ported from getsentry/cli#1653 and getsentry/cli#1616, which are being closed with the repo archive.

via BYK.

--

View Junior Session in Sentry

Two kinds of user-environment failures still reached Sentry as issues:

- undici aborts a response body with `TypeError: terminated` when the
  connection drops mid-stream (CLI-2AD). GET bodies are already retried,
  so one that still escapes is the same offline/proxy noise as
  `fetch failed` and is now treated as a network error.
- A missing, non-directory, or unreadable sourcemap directory throws a
  ValidationError with field "directory" (CLI-1FN). It is now silenced
  like the missing --input file case. Other ValidationErrors stay
  captured.

Ported from getsentry/cli#1653 and getsentry/cli#1616.

Co-Authored-By: BYK <burak.kaya@sentry.io>
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 22, 2026 6:31pm UTC

Request Review

@BYK
BYK merged commit 5e7b12b into main Oct 23, 2026
26 checks passed
@BYK
BYK deleted the fix/cli-silence-env-noise branch October 23, 2026 11:19
joshuawayzwright pushed a commit to joshuawayzwright/sentry-mcp that referenced this pull request Nov 16, 2026
…etsentry#1606)

## Summary

`sentry project list --limit 200` was sending `per_page=200`. The org
projects endpoint returns **400** for that (it does not silently cap at
100 like some other list APIs), so agents that want a slug map of a
large org just retry 300/500 and fail the same way.

`--limit` is now a total. Each request is capped at `API_MAX_PER_PAGE`
(100) and `autoPaginate` fills the rest — same helper issue/trace list
already use. `listProjectsPaginated` also clamps so a raw oversized
`per_page` cannot leak through.

Shared `handleOrgAll` (team/repo list) gets the same auto-pagination, so
`--limit 250` actually returns 250 items instead of one capped page of
100.

## Test plan

- [ ] `sentry project list <org>/ --limit 200 --json --fields slug,name`
returns up to 200 projects (or fewer if the org is smaller), no 400
- [ ] `sentry project list <org>/ --limit 25` still does a single
request
- [ ] `sentry project list <org>/ -c next` still walks one page at the
requested limit
- [ ] unit tests: `pnpm exec vitest run
test/lib/api-client.coverage.test.ts test/commands/project/list.test.ts
test/lib/org-list.test.ts` from `packages/cli`


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

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
joshuawayzwright pushed a commit to joshuawayzwright/sentry-mcp that referenced this pull request Nov 16, 2026
…etsentry#1606)

## Summary

`sentry project list --limit 200` was sending `per_page=200`. The org
projects endpoint returns **400** for that (it does not silently cap at
100 like some other list APIs), so agents that want a slug map of a
large org just retry 300/500 and fail the same way.

`--limit` is now a total. Each request is capped at `API_MAX_PER_PAGE`
(100) and `autoPaginate` fills the rest — same helper issue/trace list
already use. `listProjectsPaginated` also clamps so a raw oversized
`per_page` cannot leak through.

Shared `handleOrgAll` (team/repo list) gets the same auto-pagination, so
`--limit 250` actually returns 250 items instead of one capped page of
100.

## Test plan

- [ ] `sentry project list <org>/ --limit 200 --json --fields slug,name`
returns up to 200 projects (or fewer if the org is smaller), no 400
- [ ] `sentry project list <org>/ --limit 25` still does a single
request
- [ ] `sentry project list <org>/ -c next` still walks one page at the
requested limit
- [ ] unit tests: `pnpm exec vitest run
test/lib/api-client.coverage.test.ts test/commands/project/list.test.ts
test/lib/org-list.test.ts` from `packages/cli`


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

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
joshuawayzwright pushed a commit to joshuawayzwright/sentry-mcp that referenced this pull request Nov 16, 2026
## Summary

`paginate()` currently uses the same `per_page` for every request. A
limit of 150 therefore fetches 100 + 100 rows, trims the last 50, and
correctly drops the server cursor because using it would skip those
trimmed rows.

Track the remaining budget inside `paginate()` so that request becomes
100 + 50 and the final cursor points at the first unreturned row.
`autoPaginate()` remains unchanged: same signature, same cursor loop,
and the same defensive trim-and-drop behavior when an endpoint ignores
`per_page`.

Split out of getsentry#1606 so the shared helper behavior can be reviewed
independently.

## Test plan

- `pnpm exec vitest run test/lib/api/infrastructure.test.ts
test/lib/auto-paginate.property.test.ts test/lib/api/traces.test.ts
test/lib/api/replays.test.ts test/lib/api/logs.test.ts
test/lib/api/conversations.test.ts`
- `pnpm run lint`
- generate schema/docs/SDK, then `pnpm exec tsc --noEmit`

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

Co-authored-by: Cursor <cursoragent@cursor.com>
joshuawayzwright pushed a commit to joshuawayzwright/sentry-mcp that referenced this pull request Nov 16, 2026
## Summary

`paginate()` currently uses the same `per_page` for every request. A
limit of 150 therefore fetches 100 + 100 rows, trims the last 50, and
correctly drops the server cursor because using it would skip those
trimmed rows.

Track the remaining budget inside `paginate()` so that request becomes
100 + 50 and the final cursor points at the first unreturned row.
`autoPaginate()` remains unchanged: same signature, same cursor loop,
and the same defensive trim-and-drop behavior when an endpoint ignores
`per_page`.

Split out of getsentry#1606 so the shared helper behavior can be reviewed
independently.

## Test plan

- `pnpm exec vitest run test/lib/api/infrastructure.test.ts
test/lib/auto-paginate.property.test.ts test/lib/api/traces.test.ts
test/lib/api/replays.test.ts test/lib/api/logs.test.ts
test/lib/api/conversations.test.ts`
- `pnpm run lint`
- generate schema/docs/SDK, then `pnpm exec tsc --noEmit`

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

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

This branch was previously deployed

1 inactive deployment
Preview — 48121594 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant