Skip to content

🥅 server: skip sentry capture for expected liquidity errors#727

Open
cruzdanilo wants to merge 1 commit intomainfrom
insufficient
Open

🥅 server: skip sentry capture for expected liquidity errors#727
cruzdanilo wants to merge 1 commit intomainfrom
insufficient

Conversation

@cruzdanilo
Copy link
Member

@cruzdanilo cruzdanilo commented Feb 6, 2026

closes #663


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: 8ae07a1

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

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Warning

Rate limit exceeded

@cruzdanilo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch insufficient

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.

@gemini-code-assist
Copy link

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 refines the error reporting mechanism within the server's panda hook. By introducing conditional Sentry exception capturing, it ensures that anticipated and gracefully handled errors, such as those indicating insufficient account liquidity, no longer generate unnecessary alerts. This change aims to reduce noise in error monitoring, allowing developers to focus on more critical and unexpected issues.

Highlights

  • Sentry Exclusion for Liquidity Errors: Sentry will no longer capture exceptions for InsufficientAccountLiquidity errors (status code 557), as these are now considered expected and handled scenarios.
  • Refactored Error Capture Logic: The captureException calls in server/hooks/panda.ts have been re-positioned and made conditional to ensure that only truly unexpected or unhandled contract errors are reported to Sentry, reducing alert noise.
  • Enhanced Error Handling Tests: Unit tests in server/test/hooks/panda.test.ts were updated to explicitly verify that Sentry's captureException is correctly called or skipped based on the error type and status code, including a new test case for 'replay' errors.
Changelog
  • .changeset/many-streets-travel.md
    • Added a new changeset entry documenting the skipping of Sentry capture for expected liquidity errors.
  • server/hooks/panda.ts
    • Modified the error handling flow to prevent Sentry from capturing exceptions for InsufficientAccountLiquidity errors (status code 557).
    • Adjusted the placement of generic captureException calls for contract errors to ensure they are only triggered for unhandled cases.
  • server/test/hooks/panda.test.ts
    • Introduced a new test case for 'replay' errors (status code 558) to verify Sentry capture behavior.
    • Updated existing tests to assert the correct Sentry captureException behavior for insufficient liquidity and generic transaction reverted errors.
Activity
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.

Copy link

@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

Copy link

@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

The pull request successfully implements the logic to selectively skip Sentry error capture for expected liquidity errors, specifically InsufficientAccountLiquidity (status code 557). The changes ensure that only truly unhandled or unexpected contract errors are reported to Sentry, reducing noise from known and handled conditions. The accompanying tests validate this behavior, confirming that captureException is not called for InsufficientAccountLiquidity errors, but is correctly called for other contract errors like Replay or generic transaction reverts. This is a good improvement for error monitoring and clarity.

Comment on lines +147 to +154
vi.spyOn(traceClient, "traceCall").mockResolvedValue({ ...callFrame, output: "0xb5a78004" });

await database.insert(cards).values([{ id: "replay", credentialId: "cred", lastFour: "2222", mode: 4 }]);

const response = await appClient.index.$post({
...authorization,
json: {
...authorization.json,
Copy link

Choose a reason for hiding this comment

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

Bug: The error handler in server/hooks/panda.ts uses "InsufficientAccountLiquidity" but the contract throws "InsufficientLiquidity", causing incorrect error handling for liquidity failures.
Severity: HIGH

Suggested Fix

In server/hooks/panda.ts at line 352, change the case "InsufficientAccountLiquidity" to "InsufficientLiquidity" to match the custom error name defined and thrown by the Solidity contract.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: server/test/hooks/panda.test.ts#L147-L154

Potential issue: The error handler in `server/hooks/panda.ts` at line 352 incorrectly
checks for the error name `"InsufficientAccountLiquidity"`. The corresponding Solidity
contract actually throws an error named `"InsufficientLiquidity"`. This mismatch causes
the `switch` statement to fail, leading to a fall-through case. As a result,
transactions failing due to insufficient liquidity will incorrectly return a generic
`PandaError` with status code 550 instead of the intended specific error with status
code 557. This also causes these expected errors to be unnecessarily captured by Sentry,
creating noise.

Did we get this right? 👍 / 👎 to inform future reviews.

@sentry
Copy link

sentry bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.07%. Comparing base (d9866f9) to head (8ae07a1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #727      +/-   ##
==========================================
+ Coverage   68.05%   68.07%   +0.01%     
==========================================
  Files         206      206              
  Lines        6784     6785       +1     
  Branches     2117     2118       +1     
==========================================
+ Hits         4617     4619       +2     
  Misses       1986     1986              
+ Partials      181      180       -1     
Flag Coverage Δ
e2e 52.77% <0.00%> (-0.03%) ⬇️

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.

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.

server: InsufficientAccountLiquidity should not be reported to sentry as an error

1 participant