fix(hono): Do not capture 3xx and 4xx errors and add tests#20640
fix(hono): Do not capture 3xx and 4xx errors and add tests#20640
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1dfe17a. Configure here.
| }); | ||
|
|
||
| it('captures error regardless of status code', () => { | ||
| it('captures 5xx HTTPException', () => { |
There was a problem hiding this comment.
Test doesn't verify claimed 5xx HTTPException capture behavior
Medium Severity
The test was renamed from "captures error regardless of status code" to "captures 5xx HTTPException" but the body was not updated. It still uses a plain Error('not found') (no status property) with createMockContext(404, error). Since isExpectedError checks error.status (not context.res.status), a plain Error always returns false from isExpectedError, so captureException is called regardless. The test passes coincidentally and doesn't exercise the new isExpectedError filtering at all. There's also no unit test verifying that an error with a 4xx status property is NOT captured by responseHandler.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 1dfe17a. Configure here.
size-limit report 📦
|
|
|
||
| expect(errorEvent.exception?.values?.[0]?.value).toBe('Error caught by custom onError'); | ||
| expect(errorEvent.exception?.values?.[0]?.mechanism).toEqual({ | ||
| handled: false, |
There was a problem hiding this comment.
Not a 100% sure on this one, but according to our develop docs, it's not handled as this was captured by a global error handler (onError).
https://develop.sentry.dev/sdk/telemetry/errors/#concepts


Add tests around error capturing in Hono and adds condition to not capture 3xx and 4xx errors.
Also removes some redundant tests and moves all error-related tests to
errors.test.ts