Skip to content

fix(cli): Verify only on telemetry that matches the filters - #2430

Merged
MathurAditya724 merged 4 commits into
mainfrom
fix/local-verify-filters
Nov 19, 2026
Merged

MathurAditya724 merged 4 commits into
mainfrom
fix/local-verify-filters

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

sentry local run --verify passed as soon as any envelope arrived. An app that only calls Sentry.init({}) can send a session envelope, so it "verified" even with -f error and no error.

Now verify waits for an item that the -f filters would show in the tail, using the same filter check. With no filters, any item counts except sessions and client reports, so cron check-ins, feedback, metrics and profiles verify too. If the SDK connected but only sent things that don't count, the error says so instead of "no events received". The timeout, exit code 64 and the hints otherwise stay the same.

Before:

$ sentry local run --verify -f error -- node initonly.cjs
Setup verified — your app is sending events to Sentry Local
$ echo $?
0

After:

$ sentry local run --verify -f error --timeout 4 -- node initonly.cjs
Error: Verification timed out after 4s — no events received from the SDK
$ echo $?
64

$ sentry local run --verify -f error --timeout 4 -- node sessiononly.cjs
Error: Verification timed out after 4s: the SDK connected but sent only session (nothing matching -f error)

via @MathurAditya724.

--

View Session [Sentry]

`local run --verify` passed on the first envelope of any kind, so an app
that only called Sentry.init() verified from its session envelope, and
`-f error` verified without any error.

Count an envelope only when it holds an item the active filters show,
through the same filter check the tail uses. With no filters, only
telemetry counts: errors, transactions, spans, logs and replays, not
sessions or client reports.

Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
cli Ready Ready Preview Nov 19, 2026 8:01pm UTC
sentry-local Ready Ready Preview Nov 19, 2026 8:01pm UTC

Request Review

Treat every item type except session, sessions and client_report as
telemetry for --verify, so check-ins, feedback, metrics and profiles
verify a setup, and item types that SDKs add later count too.

When only uncounted items arrived, the timeout and early-exit errors now
say the SDK connected and what it sent, instead of "no events received"
and the DSN and port hints, which don't apply then.

Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>

@MathurAditya724 MathurAditya724 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent real CLI testing found an actionable gap; see the inline reproduction and requested regression. Holding merge until it is addressed.

Comment thread packages/cli/src/commands/local/run.ts Resolved
Envelope item types come from untrusted HTTP input. Run them through the
same sanitize helper the Local tail uses before they reach the "SDK
connected but sent only …" error, so ANSI/OSC escapes, control
characters, BiDi controls and newlines can't reach the terminal.
@MathurAditya724

Copy link
Copy Markdown
Member

The sanitization update is the right fix. A merge attempt against main after #2434 now conflicts in apps/cli-docs/src/content/docs/exit-codes.md and packages/cli/plugins/sentry-cli/skills/sentry-cli/references/local.md. Please rebase, preserving both the matching-telemetry verify text and the new timeout exit-124/help text. Source files merge cleanly; I am retesting the independent terminal-injection and CLI filter probes. A conflict-free updated head and its hosted checks are still required before merge.

# Conflicts:
#	apps/cli-docs/src/content/docs/exit-codes.md
#	packages/cli/plugins/sentry-cli/skills/sentry-cli/references/local.md

@MathurAditya724 MathurAditya724 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested ebfe404 integrated with current main. The prior diagnostic injection finding is addressed with the shared sanitizer. Reviewed filter handling, AI child spans, housekeeping-only envelopes, timeout interaction, and rebased documentation.

Validation: full workspace tsc, lint and test passed (CLI 13,682 tests; MCP core 2,469; Cloudflare 476; Local 501). Independent real CLI subprocesses confirmed housekeeping and filtered-out deliveries fail verification, matching errors and AI child spans succeed, and ANSI/newline envelope types cannot forge terminal diagnostics. No remaining actionable findings.

@MathurAditya724
MathurAditya724 merged commit 4890786 into main Nov 19, 2026
31 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/local-verify-filters branch November 19, 2026 20:55
MathurAditya724 added a commit that referenced this pull request Nov 19, 2026
The receiver accepted anything posted to it. An empty body or a body
whose first line isn't a JSON object got a 204 and took a retention
slot. An envelope whose event item wasn't JSON showed up as a fake error
in the tail and in `event list`.

Before:
```
POST /stream  (empty body)              ->  204, stored
POST /stream  "{not json\n…"            ->  204, stored
POST /stream  '{}\n{"type":"event"}\nnot-json'  ->  204, shows "[ERROR] Error: Unknown error"
```

After:
```
POST /stream  (empty body)              ->  400 {"error":"The envelope is empty."}, nothing stored
POST /stream  "{not json\n…"            ->  400 {"error":"The envelope header is not a JSON object."}, nothing stored
POST /stream  '{}\n{"type":"event"}\nnot-json'  ->  accepted, shows "[INVALID] Event payload is not JSON"
```

Relay also answers 400 for the first two cases, and it accepts the last
one and drops it later. So the last case is still accepted here, but
it's labelled `invalid` (`"type":"invalid"` in JSON output) instead of
counting as an error. It still shows under `-f error`. A body that fails
to decompress now gets an `{"error": …}` reason too. Unknown item types
and items without `length` are still accepted. The size limits and the
other status codes stay the same.

`--verify` now checks each item. An invalid event never counts, and
neither do sessions or client reports. With `-f`, only items those
filters show count. Before, an invalid event sent next to a session was
enough to pass. This uses the same check as #2430, so whichever lands
second only has a small merge.

Possible follow-up: the hosted viewer labels events its own way, so it
may still show that last case as an error.

<!-- junior-request-attribution:start -->
via @MathurAditya724.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A994a746adac832d3b342d71d10e4428b -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A994a746adac832d3b342d71d10e4428b)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A994a746adac832d3b342d71d10e4428b/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
Co-authored-by: mathuraditya724 <mathuraditya724@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>

This branch was successfully deployed

2 active deployments
Preview – sentry-local — ebfe4048 Deployed Nov 19, 2026 by vercel[bot]
Preview – cli — ebfe4048 Deployed Nov 19, 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