Sentry v2: route numeric DSN, ingest JS/SvelteKit events, resolve JS source (#338)#339
Merged
butschster merged 5 commits intoJun 9, 2026
Merged
Conversation
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.
This was referenced Jun 9, 2026
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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".event_id(b355bab). The detail endpoint resolves by either internal id orevent_id(the id the frontend route and SDK use), and loads exceptions/breadcrumbs by the internal PK.d27c389).sentry.javascript.*(SvelteKit) sendsbreadcrumbsas 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).BreadcrumbListnow accepts both shapes.70baeaa). Browser frames carry onlyfilename(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 attachpre/context/post_context. Best-effort, only http(s) frames lacking source.501638d). Dev servers serve transformed/bundled modules, so the fetched source was post-processed. Parse the module's source map (inlinedata:URI or external.map), VLQ-decodemappings, and translate the generated line/col to the original position usingsourcesContent— 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.goand the source-map resolution tests.go test ./...passes.Frontend counterpart
Display-side fixes (render top-level/
threadsstacktraces, auto-open the first code-bearing frame, cleanapp:///node paths) live in the frontend PR — linked below.Related
Refs #338