Skip to content

fix(nswitch): Mark crashes synthetic so titles fall back to the crashing function - #6253

Merged
JoshuaMoelans merged 16 commits into
masterfrom
fix/switch-events
Aug 31, 2026
Merged

fix(nswitch): Mark crashes synthetic so titles fall back to the crashing function#6253
JoshuaMoelans merged 16 commits into
masterfrom
fix/switch-events

Conversation

@mujacica

@mujacica mujacica commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Switch crash events are titled with Nintendo's raw abort result code (e.g. 2168-0002 ResultAccessViolationData), hiding the crashing function and burying real regressions in a sea of identical-looking titles (getsentry/sentry-switch#153).

This PR marks the exception synthetic, the same treatment minidumps get via write_native_placeholder, so Sentry falls back to the symbolicated crashing function for the title. The result code stays queryable on exception.type and the mechanism tag. It also re-asserts level: fatal — Nintendo forwards crashes as fatal, but the DyingMessage scope patch is the merge base and downgrades it to error — and hardens dying-message parsing against a panic on payloads shorter than the magic number.

Validated end-to-end against a real CRPortal-forwarded crash (captured by pointing a CRPortal Import Destination at a local Relay in processing mode): before → title 2168-0002 ResultAccessViolationData: …, after → title nnMain, level fatal. Details on the original issue.


Event before fix:
https://sentry-sdks.sentry.io/issues/7671819961/?project=4509910938550273&query=is%3Aunresolved&referrer=issue-stream&sort=recommended

Event after fix:
https://sentry-sdks.sentry.io/issues/7671893807/?project=4509910938550273&query=is%3Aunresolved&referrer=issue-stream&sort=recommended


Related PRs:
sentry - getsentry/sentry#123020
options-automator - https://github.com/getsentry/sentry-options-automator/pull/9446

mujacica added 3 commits July 22, 2026 10:57
The native crash helpers are only compiled with the processing feature
(pub use self::native::* is cfg-gated), so calling reshape_switch_crash
unconditionally broke the default-features build (E0425). Wrap the call
in if_processing! like the minidump path, and guard the now-conditional
mut binding.
Comment thread relay-server/src/processing/errors/errors/nswitch.rs
…cking

Item::attachment_type can return NintendoSwitchDyingMessage from an
explicitly set item header, bypassing the starts_with(magic) guard used
when inferring the type. expand_dying_message then called Bytes::advance
past the payload length, which panics and crashes the processing worker
(DoS). Validate the magic up front and return an error instead.

Reported by Warden wrdn-dos-review.
Comment on lines +522 to +526
let envelope = r#"{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"}
{"type":"event"}
{"level":"error","exception":{"values":[{"type":"2168-0002 ResultAccessViolationData","value":"Data access to an invalid memory region was performed. (2: Access Violation Data)","stacktrace":{"frames":[{"function":"ASentryTowerTurret::Shoot"}]}}]}}
{"type":"attachment","filename":"dying_message.dat","length":<len>}
"#

@JoshuaMoelans JoshuaMoelans Aug 14, 2026

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.

Q: we have this "fake" json envelope constructed here, but we could add a test with an actual captured one from our switch-SDK integration tests. Not sure if this is somehow not advised?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Ingest's perspective there's no problem using a captured envelope.

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.

@loewenheim I added fixtures captured from our own CI tests passing through a local relay in ef999f2 ; I'm not sure if there is a cleaner pattern to 'get' those files into the test (the ../../../ doesn't look that clean 🥲 )

A raw capture of what CRPortal actually delivers (via an Import
Destination pointed at a local Relay) showed the forwarded event already
carries mechanism.handled: false and level: fatal. The error level seen
on stored events comes from the DyingMessage scope patch winning the
merge, not from Nintendo.

Remove the redundant handled write and correct the reshape docs, test
premise, and changelog accordingly: synthetic remains the title fix, and
the level write re-asserts the severity the merge downgraded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JoshuaMoelans JoshuaMoelans changed the title fix(switch): Match the event types of other console/gaming errors fix(nswitch): Mark crashes synthetic so titles fall back to the crashing function Aug 14, 2026
@JoshuaMoelans
JoshuaMoelans marked this pull request as ready for review August 14, 2026 14:44
@JoshuaMoelans
JoshuaMoelans requested a review from a team as a code owner August 14, 2026 14:44
@JoshuaMoelans

Copy link
Copy Markdown
Member

we want to roll this out instead of making the change for every single sentry-switch user at once; probably in phases (ourselves -> select customers -> everyone). @mujacica are you familiar with setting up feature flags for this kind of thing? (if not, I can look into it)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6c2c1d0. Configure here.

Comment thread relay-server/src/processing/errors/errors/nswitch.rs Outdated

@loewenheim loewenheim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some nits, otherwise this looks good

Comment thread relay-server/src/processing/errors/errors/nswitch.rs Outdated
Comment on lines +522 to +526
let envelope = r#"{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"}
{"type":"event"}
{"level":"error","exception":{"values":[{"type":"2168-0002 ResultAccessViolationData","value":"Data access to an invalid memory region was performed. (2: Access Violation Data)","stacktrace":{"frames":[{"function":"ASentryTowerTurret::Shoot"}]}}]}}
{"type":"attachment","filename":"dying_message.dat","length":<len>}
"#

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Ingest's perspective there's no problem using a captured envelope.

Comment thread relay-server/src/utils/native.rs Outdated
Comment thread relay-server/src/utils/native.rs Outdated
Comment thread relay-server/src/utils/native.rs Outdated
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Comment thread relay-server/src/processing/errors/errors/nswitch.rs
@JoshuaMoelans
JoshuaMoelans added this pull request to the merge queue Aug 31, 2026
Merged via the queue into master with commit a9ecd62 Aug 31, 2026
35 checks passed
@JoshuaMoelans
JoshuaMoelans deleted the fix/switch-events branch August 31, 2026 12:13
JoshuaMoelans added a commit to getsentry/sentry that referenced this pull request Aug 31, 2026
To be merged after the related relay PR
getsentry/relay#6253

Merge after this: related options-automator PR
getsentry/sentry-options-automator#9446
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.

3 participants