[DO NOT MERGE] feat(core): add opt-in assertion instrumentation - #6592
[DO NOT MERGE] feat(core): add opt-in assertion instrumentation#6592antonis wants to merge 11 commits into
5 issues
find-bugs: Found 5 issues (4 medium, 1 low)
Medium
Destructured console.assert miscompiled as throwing assert - `packages/core/etc/sentry-react-native.api.md:162`
The assertion Babel plugin rewrites const { assert } = console; assert(false) with rethrow: true, turning a report-only console.assert into a throwing assertion that crashes after capturing.
flattenValues crashes when captured value has throwing toString - `packages/core/src/js/assertion.ts:127`
Wrap String(value) in a try-catch so a throwing toString or [Symbol.toPrimitive] doesn't break the reporting path and cause double-capture.
SDK self-exclusion breaks on Windows paths - `packages/core/src/js/index.ts:120-197`
SENTRY_SDK_PATH_MARKERS uses forward-slash literals, but Metro/Babel filename may contain backslashes on Windows, causing the plugin to fail to skip Sentry's own files and risking a self-referential require('@sentry/react-native') if any assertion pragma exists in SDK source.
Also found at:
packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:197
collectValueIdentifiers emits out-of-scope references for nested bindings - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:278`
Identifiers bound inside nested functions (e.g. arrow-function parameters) are collected and then referenced in the emitted values object at the assertion call site, where they are out of scope and cause a ReferenceError at runtime.
Low
captureAssertionViolation crashes when values is null - `packages/core/src/js/assertion.ts:186-188`
The guard if (values !== undefined) allows null to reach flattenValues, where Object.keys(null) throws a TypeError. Change the check to if (values != null) to safely reject both null and undefined.
⏱ 65m 4s · 7.8M in / 453.6k out · $4.69
Annotations
Check warning on line 162 in packages/core/etc/sentry-react-native.api.md
sentry-warden / warden: find-bugs
Destructured console.assert miscompiled as throwing assert
The assertion Babel plugin rewrites `const { assert } = console; assert(false)` with `rethrow: true`, turning a report-only `console.assert` into a throwing assertion that crashes after capturing.
Check warning on line 127 in packages/core/src/js/assertion.ts
sentry-warden / warden: find-bugs
flattenValues crashes when captured value has throwing toString
Wrap `String(value)` in a try-catch so a throwing `toString` or `[Symbol.toPrimitive]` doesn't break the reporting path and cause double-capture.
Check warning on line 197 in packages/core/src/js/index.ts
sentry-warden / warden: find-bugs
SDK self-exclusion breaks on Windows paths
`SENTRY_SDK_PATH_MARKERS` uses forward-slash literals, but Metro/Babel `filename` may contain backslashes on Windows, causing the plugin to fail to skip Sentry's own files and risking a self-referential `require('@sentry/react-native')` if any assertion pragma exists in SDK source.
Check warning on line 197 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: find-bugs
[LL5-LAG] SDK self-exclusion breaks on Windows paths (additional location)
`SENTRY_SDK_PATH_MARKERS` uses forward-slash literals, but Metro/Babel `filename` may contain backslashes on Windows, causing the plugin to fail to skip Sentry's own files and risking a self-referential `require('@sentry/react-native')` if any assertion pragma exists in SDK source.
Check warning on line 278 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: find-bugs
collectValueIdentifiers emits out-of-scope references for nested bindings
Identifiers bound inside nested functions (e.g. arrow-function parameters) are collected and then referenced in the emitted `values` object at the assertion call site, where they are out of scope and cause a `ReferenceError` at runtime.