Skip to content

Sentry v2: route numeric DSN, ingest JS/SvelteKit events, resolve JS source (#338)#339

Merged
butschster merged 5 commits into
buggregator:masterfrom
FluffyDiscord:fix/sentry-v2-issues
Jun 9, 2026
Merged

Sentry v2: route numeric DSN, ingest JS/SvelteKit events, resolve JS source (#338)#339
butschster merged 5 commits into
buggregator:masterfrom
FluffyDiscord:fix/sentry-v2-issues

Conversation

@FluffyDiscord

@FluffyDiscord FluffyDiscord commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes the Sentry-module v2 long-standing issues bundled in #338, focused on getting Sentry/JS (SvelteKit) error events to ingest and display correctly.

What's fixed

  • Numeric DSN project → default project (81fc4ef). The JS SDK forces a numeric DSN project id (http://key@host/1); all-digit segments now route to the default project instead of being orphaned under an invisible project "1".
  • Exception detail resolvable by event_id (b355bab). The detail endpoint resolves by either internal id or event_id (the id the frontend route and SDK use), and loads exceptions/breadcrumbs by the internal PK.
  • Breadcrumbs bare-array parsing (d27c389). sentry.javascript.* (SvelteKit) sends breadcrumbs as a bare JSON array; the struct only accepted the {"values":[…]} object form, so the whole error event failed to unmarshal and never reached the sentry tables (empty exceptions list, 404 on detail). BreadcrumbList now accepts both shapes.
  • Source code for browser/JS frames (70baeaa). Browser frames carry only filename(URL)+lineno+colno, no source — and the frontend can't fetch it (CORS). Resolve it server-side (no CORS): fetch the file the frame points at and attach pre/context/post_context. Best-effort, only http(s) frames lacking source.
  • Original source via source maps (501638d). Dev servers serve transformed/bundled modules, so the fetched source was post-processed. Parse the module's source map (inline data: URI or external .map), VLQ-decode mappings, and translate the generated line/col to the original position using sourcesContent — showing the developer's actual .svelte/.ts, not the compiled output.

Tests

Added modules/sentry/types_test.go (breadcrumbs dual-form + SvelteKit payload), modules/sentry/source_context_test.go and the source-map resolution tests. go test ./... passes.

Frontend counterpart

Display-side fixes (render top-level/threads stacktraces, auto-open the first code-bearing frame, clean app:/// node paths) live in the frontend PR — linked below.

Related

Refs #338

Rosta Kaleta added 5 commits June 5, 2026 14:56
The Sentry JavaScript SDK rejects non-numeric DSN project ids, forcing
users onto a numeric DSN such as http://key@host/1. Buggregator parsed
that path segment as the project key and (since buggregator#335) auto-registered an
orphan project named "1", so the event never reached the user-visible
"default" project.

resolveProject now maps a purely-numeric DSN segment to empty, so the
existing pipeline routes the event to the default project (or to an
X-Buggregator-Project override). Named segments are preserved unchanged,
covering both the /store and /envelope ingestion paths. Transactions,
spans and logs are project-agnostic and unaffected.

Fixes buggregator#338.
The exceptions list returns event_id and the frontend routes to
/sentry/event/{event_id}, but the detail endpoint matched only the
internal id, so any lookup by event_id returned 404. It now resolves by
either key (preferring the internal id) and feeds the resolved internal
id to the breadcrumb/exception child lookups and the response id, so the
detail no longer comes back with an empty stacktrace. Issue buggregator#338.
JavaScript SDKs (sentry.javascript.sveltekit etc.) send breadcrumbs as a
bare JSON array, while Python/PHP send the {"values": [...]} interface
object. The struct only accepted the object form, so a SvelteKit browser
error failed to unmarshal and never reached the sentry tables (empty
exceptions list, 404 on the detail endpoint). Accept both shapes.
Browser JS SDKs send error frames carrying only filename(URL), lineno and
colno - no source. The frontend can't fetch that source itself (the dev
server is a different origin and CORS blocks it), so frames rendered with
no code. Resolve it server-side (no CORS): fetch the file the frame points
at and attach pre_context/context_line/post_context. Best-effort and
self-limiting - only http(s) filenames without existing source are touched,
which naturally scopes it to browser/JS frames.
Dev servers serve transformed/bundled modules, so the fetched source showed
post-processed code (Svelte/Vite output) instead of the developer's file. Parse
the module's source map (inline data: URI or external .map), VLQ-decode the
mappings, and translate the frame's generated line/col to the original position,
using sourcesContent for the pristine source. Falls back to the transformed
lines when no usable source map is present.
@FluffyDiscord

Copy link
Copy Markdown
Contributor Author

this makes JS errors, or at least sveltekit client and ssr errors, actually usable in buggregator, before this and the frontend part, they were either not handled at all, handled as http dumps, or partially handled with hacks on the js sentry part with major issues @butschster please review this, i have used claude to code all of this since Go is not my forte and my Vue experience is limited

@butschster butschster merged commit 9ebbc59 into buggregator:master Jun 9, 2026
1 check passed
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.

2 participants