Skip to content

🥅 server: enrich sentry fingerprint with revert reason#740

Merged
cruzdanilo merged 1 commit intomainfrom
sentry
Feb 7, 2026
Merged

🥅 server: enrich sentry fingerprint with revert reason#740
cruzdanilo merged 1 commit intomainfrom
sentry

Conversation

@cruzdanilo
Copy link
Copy Markdown
Member

@cruzdanilo cruzdanilo commented Feb 7, 2026


Open with Devin

Summary by CodeRabbit

  • Improvements

    • Enhanced error tracking and reporting system for contract transaction failures with improved fingerprinting capabilities to differentiate error types across various revert scenarios.
  • Tests

    • Expanded test suite to validate error capture and reporting behavior, with enhanced verification of error handling during proposal execution and withdrawal operations.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 10160fb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @cruzdanilo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the server's error monitoring by integrating detailed smart contract revert reasons directly into Sentry error fingerprints. This change provides more granular context for blockchain-related exceptions, enabling more efficient identification, categorization, and resolution of issues stemming from contract execution failures.

Highlights

  • Sentry Fingerprint Enrichment: Implemented logic to enrich Sentry error fingerprints with specific revert reasons, error names, or signatures when a ContractFunctionRevertedError is encountered. This improves error grouping and debugging for smart contract interactions.
  • Error Handling in Hooks: Applied the Sentry fingerprint enrichment to captureException calls within the server/hooks/block.ts and server/hooks/panda.ts files, specifically targeting errors originating from contract function reverts.
  • Enhanced Test Coverage: Added and updated unit tests in server/test/hooks/block.test.ts and server/test/hooks/panda.test.ts to verify that Sentry's captureException is called with the expected, enriched fingerprints for various contract revert scenarios, ensuring the new error reporting mechanism works as intended.
Changelog
  • .changeset/bright-falcon-glow.md
    • Added a new changeset file documenting the Sentry fingerprint enrichment for contract revert reasons.
  • server/hooks/block.ts
    • Modified the captureException call to include a dynamic fingerprint array. This fingerprint now incorporates the reason, errorName, or signature from ContractFunctionRevertedError if the error is an instance of BaseError with a ContractFunctionRevertedError cause.
  • server/hooks/panda.ts
    • Updated captureException to include a dynamic fingerprint that extracts specific details from ContractFunctionRevertedError when handling contract-related exceptions, similar to the changes in block.ts.
  • server/test/hooks/block.test.ts
    • Imported captureException from @sentry/node.
    • Added new expect assertions to verify that captureException is called with the expected fingerprint values (e.g., "execution reverted", "NotNext") when contract execution errors occur.
    • Added vi.mock("@sentry/node", { spy: true }); to mock Sentry for testing purposes.
  • server/test/hooks/panda.test.ts
    • Imported encodeErrorResult for more accurate error simulation.
    • Updated traceClient.traceCall mocks to use encodeErrorResult for more realistic simulation of contract revert errors (e.g., "Replay", "Panic").
    • Added expect assertions to confirm that captureException receives the correct fingerprint values (e.g., "Arithmetic operation resulted in underflow or overflow.", "InsufficientLiquidity") during error handling.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 7, 2026

Walkthrough

These changes enhance Sentry error reporting by enriching error fingerprints with contract revert reasons. The hook layer (block.ts and panda.ts) now captures detailed error context when contract execution fails, with corresponding test updates verifying the new fingerprint behavior.

Changes

Cohort / File(s) Summary
Changelog
.changeset/bright-falcon-glow.md
Changelog entry declaring a patch release for "@exactly/server" with note about enriching Sentry fingerprint with revert reason.
Hook Layer Error Enrichment
server/hooks/block.ts, server/hooks/panda.ts
Adds fingerprint field to error captures for contract execution failures. Fingerprints include conditional extraction of revert reason, error name, or signature from ContractFunctionRevertedError causes, falling back to "unknown".
Test Updates
server/test/hooks/block.test.ts, server/test/hooks/panda.test.ts
Adds Sentry error capture assertions and verifies fingerprint content. Updates panda tests to use encodeErrorResult from viem for constructing error-encoded outputs in test scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • nfmelendez
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enriching Sentry fingerprints with revert reasons across multiple server hook files.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 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 and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enriches Sentry error reports by adding a fingerprint based on the contract revert reason. This is a great improvement for error grouping and analysis. The changes are implemented in block.ts and panda.ts, with corresponding test updates to verify the new fingerprinting logic. Otherwise, the changes look good and the tests are thorough.

Copy link
Copy Markdown

@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 5 additional findings.

Open in Devin Review

@sentry
Copy link
Copy Markdown

sentry bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.27%. Comparing base (f7de431) to head (10160fb).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/hooks/panda.ts 37.50% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #740      +/-   ##
==========================================
- Coverage   67.27%   67.27%   -0.01%     
==========================================
  Files         206      206              
  Lines        6909     7080     +171     
  Branches     2151     2219      +68     
==========================================
+ Hits         4648     4763     +115     
- Misses       2078     2117      +39     
- Partials      183      200      +17     
Flag Coverage Δ
e2e 65.97% <50.00%> (-1.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@server/hooks/panda.ts`:
- Around line 385-394: The revert-reason extraction chain is duplicated where
you build the fingerprint (using contractError.cause and
ContractFunctionRevertedError); extract that fallback logic into a single helper
(e.g., export function revertReason(err: unknown): string) that returns
cause.reason ?? cause.data?.errorName ?? cause.signature ?? "unknown", replace
the inline ternary in the fingerprint construction with a call to
revertReason(contractError.cause), and update the other call site that currently
uses the same chain so both use this helper to stay in sync.

@sentry
Copy link
Copy Markdown

sentry bot commented Feb 20, 2026

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

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