[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
4 issues
code-review: Found 4 issues (1 high, 2 medium, 1 low)
High
Unprotected Number coercion in formatMessage can throw TypeError on the reporting path - `packages/core/src/js/assertion.ts:158-162`
Number(arg) in %d/%i/%f branches throws for Symbols and BigInts, crashing the assertion reporting path that is documented to never throw. Wrap these conversions in try-catch like the adjacent %j branch.
Medium
Hoisted `Error` alias breaks on module-level `Error` declarations - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:544`
The var _Error = Error injected at program top captures module-level Error bindings (e.g. an import { Error } or let/var Error), so new _Error() later throws TypeError instead of creating the intended assertion error.
Tests leak `siteId` entries into module-level `reportedSites` set - `packages/core/test/assertion.test.ts:95`
Tests that pass siteId without jest.isolateModules permanently add entries to the shared module-level reportedSites set, making the suite order-dependent and brittle against future additions that reuse a call-site id.
Low
Dangling format specifier branch untested - `packages/core/test/assertion.test.ts:234-241`
This test's title and comment describe a dangling format specifier, but messageArgs provides four values for three specifiers so the i >= args.length branch in formatMessage is never exercised here.
⏱ 20m 4s · 2.7M in / 325.0k out · $1.33
Annotations
Check failure on line 162 in packages/core/src/js/assertion.ts
sentry-warden / warden: code-review
Unprotected Number coercion in formatMessage can throw TypeError on the reporting path
`Number(arg)` in `%d`/`%i`/`%f` branches throws for Symbols and BigInts, crashing the assertion reporting path that is documented to never throw. Wrap these conversions in try-catch like the adjacent `%j` branch.
Check warning on line 544 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: code-review
Hoisted `Error` alias breaks on module-level `Error` declarations
The `var _Error = Error` injected at program top captures module-level `Error` bindings (e.g. an `import { Error }` or `let/var Error`), so `new _Error()` later throws `TypeError` instead of creating the intended assertion error.
Check warning on line 95 in packages/core/test/assertion.test.ts
sentry-warden / warden: code-review
Tests leak `siteId` entries into module-level `reportedSites` set
Tests that pass `siteId` without `jest.isolateModules` permanently add entries to the shared module-level `reportedSites` set, making the suite order-dependent and brittle against future additions that reuse a call-site id.