Skip to content

fix(webapp): collapse Prisma P1001 errors into a single Sentry issue#3632

Merged
d-cs merged 2 commits into
mainfrom
sentry-db-unreachable-fingerprint
May 18, 2026
Merged

fix(webapp): collapse Prisma P1001 errors into a single Sentry issue#3632
d-cs merged 2 commits into
mainfrom
sentry-db-unreachable-fingerprint

Conversation

@d-cs
Copy link
Copy Markdown
Collaborator

@d-cs d-cs commented May 15, 2026

Summary

  • Adds a beforeSend rule in apps/webapp/sentry.server.ts that collapses Prisma P1001 ("Can't reach database server") errors into a single Sentry issue regardless of which call site threw, by setting event.fingerprint = ["prisma-p1001-db-unreachable"] and tagging db_unreachable:true.
  • Matches both err.code === "P1001" (Prisma's KnownRequestError when a connection drops mid-query) and err.errorCode === "P1001" (InitializationError when the client fails to connect at startup).
  • Implemented as a small extensible FINGERPRINT_RULES table so further fan-out errors can be added with one entry.

Verification

End-to-end verified locally with debug: true on the SDK:

  • Real Prisma P1001 thrown from a loader (DB stopped mid-request) is captured by Sentry's Remix auto-instrumentation
  • beforeSend fires with originalException.code === "P1001", rule matches
  • event.fingerprint = ["prisma-p1001-db-unreachable"] and tags.db_unreachable = "true" applied
  • Event lands in Sentry under the new fingerprint

Test plan

  • Deploy to staging; confirm P1001 events appear under a single prisma-p1001-db-unreachable issue rather than fanning out
  • Confirm db_unreachable:true tag is filterable in Sentry
  • Verify non-P1001 errors are unaffected (event passes through beforeSend untouched)

🤖 Generated with Claude Code

DB outages currently produce hundreds of distinct Sentry issues — one per
call site — which buries other alerts. Add a beforeSend rule that detects
err.code === "P1001" (KnownRequestError when a connection drops mid-query)
or err.errorCode === "P1001" (InitializationError when the client fails to
connect at startup) and assigns a stable fingerprint plus a db_unreachable
tag so all P1001 events collapse into one issue regardless of stack trace.

The rule list is extensible — additional fan-out errors can be added with
one entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

⚠️ No Changeset found

Latest commit: 40e07f5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Review Change Stack

Walkthrough

This change introduces Sentry fingerprint-based grouping for Prisma P1001 database connectivity errors. A new FINGERPRINT_RULES configuration constant defines rules that match P1001 errors via either code or errorCode and assign a fixed fingerprint identifier along with a db_unreachable tag. A beforeSend hook is added to the Sentry init configuration that extracts the original exception from the event hint, matches it against the rules, and when a match is found, sets the event's fingerprint and merges the rule's tags into the event. Documentation is added to describe the change and note the extensible rule table for future collapsing rules.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete compared to the repository template. While it provides thorough technical details about the change and verification, it is missing required checklist items and does not follow the template structure with sections for Testing, Changelog, and Screenshots. Complete the PR description by adding the required checklist section with checkboxes, a dedicated Testing section with concrete steps, and a Changelog section. Include the Screenshots section even if empty.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: collapsing Prisma P1001 errors into a single Sentry issue, which matches the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 sentry-db-unreachable-fingerprint

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 and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@d-cs d-cs self-assigned this May 18, 2026
@d-cs d-cs marked this pull request as ready for review May 18, 2026 08:23
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@d-cs d-cs merged commit 9623e88 into main May 18, 2026
32 checks passed
@d-cs d-cs deleted the sentry-db-unreachable-fingerprint branch May 18, 2026 08:37
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.

3 participants