Skip to content

fix(backend): stop logging intentional HttpErrors as unhandled errors#1685

Open
Anexus5919 wants to merge 1 commit into
durdana3105:mainfrom
Anexus5919:fix/error-handler-double-log
Open

fix(backend): stop logging intentional HttpErrors as unhandled errors#1685
Anexus5919 wants to merge 1 commit into
durdana3105:mainfrom
Anexus5919:fix/error-handler-double-log

Conversation

@Anexus5919

Copy link
Copy Markdown

Summary

The global error handler had an unconditional console.error("Unhandled error:", err) before it classified the error, so every intentional HttpError was logged twice, and expected 4xx client errors were recorded as unhandled server errors. This removes the stray line and logs 4xx at warn, 5xx at error.

Changes

  • errorHandler.js: remove the unconditional log; log HttpError at warn (status < 500) or error (>= 500).
  • Add tests/errorHandler.test.js.

Verification

  • New test: a 401 HttpError is not logged as "Unhandled error" and is logged at warn; an unknown error is logged exactly once as unhandled; a 5xx HttpError logs at error. The test fails on the old code and passes on the fix.
  • Full backend suite passes.

Related

Fixes #1661

@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

@Anexus5919 is attempting to deploy a commit to the durdana3105's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Anexus5919, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c156c76-6efa-4320-a138-21bd0f308a2e

📥 Commits

Reviewing files that changed from the base of the PR and between 0de0e8a and fca9942.

📒 Files selected for processing (2)
  • backend/middlewares/errorHandler.js
  • backend/tests/errorHandler.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Anexus5919

Copy link
Copy Markdown
Author

@durdana3105 Kindly have a review on this pr. Thanks!

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.

Bug: global error handler logs every error as Unhandled error, double-logging and mislabeling intentional HttpErrors

1 participant