Skip to content

fix(worker): capture API route errors in Sentry#1439

Merged
brendan-kellam merged 1 commit into
mainfrom
brendan-kellam/capture-api-route-errors-in-sentry
Jul 13, 2026
Merged

fix(worker): capture API route errors in Sentry#1439
brendan-kellam merged 1 commit into
mainfrom
brendan-kellam/capture-api-route-errors-in-sentry

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • capture unhandled worker API route exceptions in Sentry
  • delegate captured errors to the existing Express error handler

Testing

  • yarn workspace @sourcebot/backend build

Note

Low Risk
Observability-only middleware; errors are still forwarded with next(error) and do not alter API logic or responses.

Overview
Adds Express error middleware on the worker API so unhandled route exceptions are reported via Sentry.captureException before next(error) continues the normal error-handling path (with express-async-errors for async handlers).

No changes to route behavior or response shapes—only observability for failures on /api/* and /metrics.

Reviewed by Cursor Bugbot for commit e4ac8d1. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error monitoring by capturing unexpected server errors.
    • Preserved standard error handling so failures continue through the normal processing flow.

@github-actions

Copy link
Copy Markdown
Contributor

@brendan-kellam your pull request is missing a changelog!

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2fd3bf0f-41d3-45c3-9b1b-4b766a2f6b76

📥 Commits

Reviewing files that changed from the base of the PR and between 53360a8 and e4ac8d1.

📒 Files selected for processing (1)
  • packages/backend/src/api.ts

Walkthrough

The backend API imports Sentry and registers Express error-handling middleware that captures propagated errors before forwarding them to the next error handler.

Changes

Backend error reporting

Layer / File(s) Summary
Sentry error middleware
packages/backend/src/api.ts
Adds Sentry and NextFunction imports, then captures propagated Express errors with Sentry before calling next(error).

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: konradstanski

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan-kellam/capture-api-route-errors-in-sentry

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.

@brendan-kellam brendan-kellam merged commit fb922cd into main Jul 13, 2026
9 of 10 checks passed
@brendan-kellam brendan-kellam deleted the brendan-kellam/capture-api-route-errors-in-sentry branch July 13, 2026 18:51
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.

1 participant