-
Notifications
You must be signed in to change notification settings - Fork 8
Snapshot tests for trace parsing/symbolization + Sentry view_url #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0df8556
f6aac8d
ea483bb
f0b95d2
2075c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: test-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
| - run: bun install --frozen-lockfile | ||
| - run: bun x tsc --noEmit | ||
| - run: bun test | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ | |
| /frontend/dist | ||
| /node_modules | ||
| /pdb-addr2line/target | ||
| scripts/harvested.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,9 @@ import { getCodeView } from "./code-view"; | |
| const BUN_REPORT_VERSION = | ||
| spawnSync(["git", "-C", import.meta.dir, "rev-parse", "--short=9", "HEAD"]).stdout.toString().trim() || "unknown"; | ||
|
|
||
| async function remapToPayload(parse: Parse, remap: Remap): Promise<Sentry.Payload> { | ||
| async function remapToPayload(parse: Parse, remap: Remap, trace_str: string): Promise<Sentry.Payload> { | ||
| const event_id = MD5.hash(parse.cache_key!, "hex"); | ||
| const view_url = `https://bun.report/${trace_str}/view`; | ||
|
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check how trace_str is passed to sendToSentry and whether it's already sanitized
rg -n -A5 'sendToSentry\(' --type=tsRepository: oven-sh/bun.report Length of output: 990 🏁 Script executed: #!/bin/bash
# Check where 'str' and 'parsed_str' come from in backend/index.ts
head -n 185 backend/index.ts | tail -n 10 && echo "---" && head -n 315 backend/index.ts | tail -n 10Repository: oven-sh/bun.report Length of output: 602 🏁 Script executed: #!/bin/bash
# Search for any URL encoding or sanitization utilities in the codebase
rg -n 'encodeURI|encodeURIComponent|sanitize|escape' --type=tsRepository: oven-sh/bun.report Length of output: 1735 🏁 Script executed: #!/bin/bash
# Look for where 'str' is defined/assigned around line 182
sed -n '150,185p' backend/index.ts | head -n 40Repository: oven-sh/bun.report Length of output: 1119 🏁 Script executed: #!/bin/bash
# Look for where 'parsed_str' is defined/assigned around line 308
sed -n '270,310p' backend/index.ts | head -n 50Repository: oven-sh/bun.report Length of output: 1240 🏁 Script executed: #!/bin/bash
# Find where remapAndRedirect is called to understand parsed_str origin
rg -n 'remapAndRedirect' backend/index.tsRepository: oven-sh/bun.report Length of output: 242 🏁 Script executed: #!/bin/bash
# Get more context around line 308 to see where parsed_str is derived
sed -n '260,315p' backend/index.tsRepository: oven-sh/bun.report Length of output: 1718 🏁 Script executed: #!/bin/bash
# Check where str is first assigned/defined before line 200
sed -n '1,200p' backend/index.ts | tail -n 60Repository: oven-sh/bun.report Length of output: 1971 Use The Example fixconst view_url = `https://bun.report/${encodeURI(trace_str)}/view`;🤖 Prompt for AI Agents |
||
|
|
||
| return [ | ||
| { | ||
|
|
@@ -31,9 +32,9 @@ async function remapToPayload(parse: Parse, remap: Remap): Promise<Sentry.Payloa | |
| dist: buildDist(parse), | ||
| level: "fatal", | ||
| transaction: remap.command, | ||
| tags: getTags(parse, remap), | ||
| tags: { ...getTags(parse, remap), ...(view_url.length <= 200 ? { view_url } : {}) }, | ||
| fingerprint: buildFingerprint(parse, remap), | ||
| extra: buildExtra(remap), | ||
| extra: buildExtra(remap, view_url), | ||
| contexts: { | ||
| runtime: { | ||
| name: "bun", | ||
|
|
@@ -43,7 +44,7 @@ async function remapToPayload(parse: Parse, remap: Remap): Promise<Sentry.Payloa | |
| device: getOSDeviceContext(parse), | ||
| }, | ||
| timestamp: new Date().getTime() / 1000, | ||
| environment: remap.embedder ?? (parse.is_canary ? "canary" : "production"), | ||
| environment: parse.is_canary ? "canary" : "production", | ||
| sdk: { | ||
| integrations: [], | ||
| name: "bun-report", | ||
|
|
@@ -78,7 +79,7 @@ function getTags(parse: Parse, remap: Remap): any { | |
| tags.baseline = true; | ||
| } | ||
|
|
||
| if (!remap.embedder && parse.is_canary) tags.canary = true; | ||
| if (parse.is_canary) tags.canary = true; | ||
|
|
||
| if (parse.env_flags != null) { | ||
| if (parse.env_flags & 0b0001) tags.wsl = true; | ||
|
|
@@ -153,15 +154,16 @@ function getOSContext(parse: Parse): Sentry.OS { | |
| * away. Surfacing it means clicking any crash shows the PR that introduced | ||
| * the crashing code (or at least, the PR the build was cut from). | ||
| */ | ||
| function buildExtra(remap: Remap): Record<string, unknown> | undefined { | ||
| function buildExtra(remap: Remap, view_url: string): Record<string, unknown> { | ||
| const extra: Record<string, unknown> = { view_url }; | ||
| const pr = remap.commit.pr; | ||
| if (!pr) return undefined; | ||
| return { | ||
| pr_number: pr.number, | ||
| pr_title: pr.title, | ||
| pr_branch: pr.ref, | ||
| pr_url: `https://github.com/oven-sh/bun/pull/${pr.number}`, | ||
| }; | ||
| if (pr) { | ||
| extra.pr_number = pr.number; | ||
| extra.pr_title = pr.title; | ||
| extra.pr_branch = pr.ref; | ||
| extra.pr_url = `https://github.com/oven-sh/bun/pull/${pr.number}`; | ||
| } | ||
| return extra; | ||
| } | ||
|
|
||
| function getOSDeviceContext(parse: Parse): Sentry.PayloadEventContexts["device"] { | ||
|
|
@@ -424,12 +426,12 @@ async function fetchEventDetails(eventId: string): Promise<any> { | |
| }; | ||
| } | ||
|
|
||
| export async function sendToSentry(parse: Parse, remap: Remap) { | ||
| export async function sendToSentry(parse: Parse, remap: Remap, trace_str: string) { | ||
| const url = process.env.SENTRY_DSN; | ||
| if (!url) { | ||
| return; | ||
| } | ||
| const event = await remapToPayload(parse, remap); | ||
| const event = await remapToPayload(parse, remap, trace_str); | ||
| const body = event.map(x => JSON.stringify(x)).join("\n"); | ||
|
|
||
| console.log(body); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider pinning Bun version for CI stability.
Using
bun-version: latestmay cause unexpected CI failures when a new Bun release introduces breaking changes. Consider pinning to a specific version (e.g.,1.2.x) for reproducible builds, or at minimum a major version constraint.♻️ Suggested fix
- uses: oven-sh/setup-bun@v2 with: - bun-version: latest + bun-version: "1.2"📝 Committable suggestion
🤖 Prompt for AI Agents