Skip to content

Tunnel sometimes doesn't receive a DSN in the payload #4088

@max-wittig

Description

@max-wittig

Environment

How do you use Sentry?
self-hosted 21.09.

Which SDK and version?
Angular SDK, maybe this issue belongs to the Angular SDK, not sure.

    "@sentry/angular": "^6.13.2",
    "@sentry/tracing": "^6.13.2",

Steps to Reproduce

  1. Setup sentry tunnel in the Angular App, like officially described
  2. Produce crash
  3. Wait for user dialog
  4. Observe 403 thrown by the upstream Sentry

Expected Result

I expected the payload to always include the upstream DSN. But it looks like this, when the user sees a
user feedback error page:

{}
{"type":"client_report"}
{"timestamp":1635253668.001,"discarded_events":[{"reason":"event_processor","category":"error","quantity":1}]}

What should I do as a tunnel here? Drop those events?

Actual Result

I would expect that every request includes a DSN in the first line, so that it can be parsed and forwarded to Sentry.

envelope = request.data
piece = envelope.split("\n")[0]
header = json.loads(piece)
dsn = urllib.parse.urlparse(header.get("dsn"))  # header.get("dsn") is empty, ParseResultBytes(scheme=b'', netloc=b'', path=b'', params=b'', query=b'', fragment=b'')
project_id = str(dsn.path).strip("/")
url = f"{settings.SENTRY_URL}/api/{project_id}/envelope/"
response = requests.post(url=url, data=envelope)  # this causes Sentry to throw a 403, <title>CSRF Verification Failed | Sentry</title>

In all other cases the payload looks correct:

{"event_id":"cdc681cf948044df86284138f4e0f21a","sent_at":"2021-10-26T13:07:49.262Z","sdk":{"name":"sentry.javascript.angular","version":"6.13.2"},"dsn":"https://0ef913cb946547adb7658bad4fbf96fe@localhost.com/87"}
{"type":"event","sample_rates":[{}]}
{"exception":{"values":[{"type":"Error","value":"Non-Error exception captured with keys: erro...}]}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions