Skip to content

fix(cli): Accept /stream and DSN envelope posts under a session ingest URL - #2396

Merged
MathurAditya724 merged 1 commit into
mainfrom
fix/local-session-ingest-paths
Nov 19, 2026
Merged

MathurAditya724 merged 1 commit into
mainfrom
fix/local-session-ingest-paths

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

--session only takes a POST to the exact ingest URL. Some SDKs build a different path, so their events get rejected:

  • PHP's Spotlight transport adds /stream to SENTRY_SPOTLIGHT.
  • Go, Rust, PHP and Ruby build <dsn path>/api/<project>/envelope/ from a DSN.

The session now also accepts <ingest URL>/stream and <ingest URL>/api/<project>/envelope/ (with or without the trailing slash). Each path still needs the ingest capability and gets the same loopback and CORS checks.

Before:

POST /_local/v1/sessions/<id>/ingest/<cap>/stream             -> 401
POST /_local/v1/sessions/<id>/ingest/<cap>/api/0/envelope/    -> 401

After:

POST /_local/v1/sessions/<id>/ingest/<cap>/stream             -> 204
POST /_local/v1/sessions/<id>/ingest/<cap>/api/0/envelope/    -> 204
POST /_local/v1/sessions/<id>/ingest/wrong/stream             -> 401

Ruby: sentry-ruby's Spotlight transport always posts to /stream at the root, which can't carry the capability. The root stays closed, since opening it would let any local process write to any session. Ruby apps can use a DSN under the ingest URL instead, with Spotlight off: http://[email protected]:8969/_local/v1/sessions/<id>/ingest/<cap>/0.

Open question: SDKs that send to a DSN (PHP at least) copy it into each envelope header. With the DSN form, the ingest capability is stored in the session's envelopes, so anyone with the read capability can see it. Should session ingest strip the dsn header?

Docs to follow: once the docs line saying --session needs SDKs that post to the exact ingest URL lands, it should list the three forms (ingest URL, plus /stream, DSN under it) and say Ruby needs the DSN form.

via @MathurAditya724.

--

View Session [Sentry]

…t URL

Session capture only accepted a POST to the exact ingest URL, so PHP's
Spotlight transport (which adds /stream) got 401, and SDKs pointed at a
DSN under the ingest URL (Go, Rust, PHP, Ruby build
<path>/api/<project>/envelope/) got 401 too.

The session now also accepts <ingest URL>/stream and
<ingest URL>/api/<project>/envelope[/]. Each path still needs the ingest
capability and gets the same loopback and CORS checks.
@vercel

vercel Bot commented Nov 18, 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 Nov 18, 2026 7:39pm UTC

Request Review

@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.

Reviewed the implementation, neighboring patterns, regression coverage, and review threads on this exact head. Local validation: 34 control-plane/lifecycle tests covering ingest aliases, scoped capability checks, CORS, and session lifecycle. No actionable findings remain; hosted checks are green.

@MathurAditya724
MathurAditya724 marked this pull request as ready for review November 19, 2026 06:44
@MathurAditya724
MathurAditya724 merged commit ab005fb into main Nov 19, 2026
25 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/local-session-ingest-paths branch November 19, 2026 06:44
MathurAditya724 added a commit that referenced this pull request Nov 19, 2026
Follow-up to #2396.

Go, Ruby and PHP copy their DSN into every envelope header. With
`--session`, that DSN holds the session's ingest key, so it ended up
stored in the session and visible to anyone with only the read link. The
daemon now removes the `dsn` key from the envelope header before it
stores or streams a session envelope. It does this after decompressing,
so gzipped PHP and Ruby requests are covered too. Only the header line
changes; the items are kept exactly as sent. Plain `local run` without a
session leaves the header alone.

Before:

```
{"event_id":"…","dsn":"http://[email protected]:8969/_local/v1/sessions/<id>/ingest/<cap>/0","sdk":{"name":"sentry.go"}}
```

After:

```
{"event_id":"…","sdk":{"name":"sentry.go"}}
```

The docs now show how each SDK sends to a session. Node and Python use
the ingest URL as is, and PHP sets `spotlight` to the ingest URL. Go,
Rust and Ruby need a DSN, which `local run --session` doesn't set, so
you create a session with `sentry local session create`, turn its
`ingestUrl` into a DSN, run the app directly, and read events with
`sentry local event list <id>`. I also removed the older docs line
saying `--session` only works with Node and Python.

Two small cleanups: the session ingest regex is now built from the list
of ingest paths so the two can't drift apart, and `..` paths under the
ingest key are covered so they can't reach the reset action.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Af689f1f928b25c03737a6ea9643eadc2)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Af689f1f928b25c03737a6ea9643eadc2/?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 <[email protected]>

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant