Skip to content

🥅 server: decode external swap errors in proposal execution#741

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

🥅 server: decode external swap errors in proposal execution#741
cruzdanilo merged 1 commit intomainfrom
decode

Conversation

@cruzdanilo
Copy link
Copy Markdown
Member

@cruzdanilo cruzdanilo commented Feb 7, 2026


Open with Devin

Summary by CodeRabbit

  • Bug Fixes
    • Improved decoding and fingerprinting of errors during proposal execution to surface external swap failures (expired transactions, insufficient output, minimal output balance violations, and wrapped/inner errors).
  • Tests
    • Added tests covering wrapped/inner error scenarios and fingerprinting behavior.
  • Chores
    • Recorded a patch release entry noting the error-decoding improvements.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 12a4f4c

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 improves the server's ability to decode and categorize errors encountered during proposal execution, especially those originating from external swap operations. By incorporating new error types and refining the error fingerprinting logic, it provides more detailed and actionable insights into transaction failures, enhancing debugging and monitoring capabilities.

Highlights

  • Enhanced Error Decoding: Added specific error definitions for ExpiredTransaction, InsufficientAmountOut, MinimalOutputBalanceViolation, and WrappedError to the combined ABI used for decoding contract calls during proposal execution.
  • Improved Error Fingerprinting: Enhanced the error fingerprinting mechanism to specifically parse WrappedError instances, extracting and including the selector argument from the wrapped error data for more precise error identification in monitoring systems.
  • New Testing Utilities: Introduced new testing utilities (encodeErrorResult, getContractError, RawContractError) to facilitate the creation and handling of complex error scenarios in tests.
  • Wrapped Error Test Coverage: Implemented a new test case to validate that WrappedError is correctly fingerprinted with its inner selector, ensuring proper error reporting for wrapped contract errors.
Changelog
  • server/hooks/block.ts
    • Expanded the ABI definitions to include new error types: ExpiredTransaction, InsufficientAmountOut, MinimalOutputBalanceViolation, and WrappedError.
    • Modified the error fingerprinting logic to specifically extract and use the selector from WrappedError data when present, improving error identification.
  • server/test/hooks/block.test.ts
    • Imported new utilities (encodeErrorResult, getContractError, RawContractError) for advanced error testing.
    • Added a new test suite (with wrapped error) to confirm that the system correctly fingerprints WrappedError by including its inner selector.
Activity
  • No human activity has been recorded on 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

Adds decoding of external (wrapped) swap errors during proposal execution: introduces four new error ABIs, updates revert fingerprinting to extract inner WrappedError selector, and adds tests that simulate wrapped contract errors to verify fingerprinting behavior.

Changes

Cohort / File(s) Summary
Changeset
.changeset/red-tigers-accept.md
Adds a patch changeset for @exactly/server with note about decoding external swap errors during proposal execution.
Error handling logic
server/hooks/block.ts
Introduces four error ABIs (ExpiredTransaction, InsufficientAmountOut, MinimalOutputBalanceViolation, WrappedError) and updates proposal execution revert fingerprinting to detect WrappedError and use its inner selector as the fingerprint (with fallbacks).
Tests
server/test/hooks/block.test.ts
Adds tests that construct and throw encoded WrappedError payloads (using encodeErrorResult, RawContractError) to assert captured ContractFunctionExecutionError fingerprints for wrapped-error, zero-data, non-contract, and unknown-signature scenarios.

Sequence Diagram

sequenceDiagram
    participant Client as executeProposal
    participant Chain as Contract Executor
    participant Decoder as Error Decoder
    participant FP as Fingerprint Builder
    participant Sentry as Logger

    Client->>Chain: call contract (proposal execution)
    Chain-->>Client: reverts with ContractFunctionRevertedError (maybe WrappedError)
    alt WrappedError encoded
        Client->>Decoder: detect & decode WrappedError
        Decoder-->>Client: inner selector (second_arg)
        Client->>FP: build ["WrappedError", inner_selector]
    else Non-wrapped revert
        Client->>FP: extract reason/errorName/signature or "unknown"
    end
    FP->>Sentry: record fingerprint
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

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 'decode external swap errors in proposal execution' directly and clearly summarizes the main change in the changeset, which adds error decoding logic for wrapped errors in proposal execution.

✏️ 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 decode

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 effectively enhances error handling for proposal execution by decoding external swap errors, which will improve debugging. The change to Sentry fingerprinting for WrappedError is a great improvement for error monitoring, making it more granular by including the inner selector. A comprehensive security audit confirmed no vulnerabilities were identified, with the implementation correctly handling error data and arguments, and safely using the selector. The implementation is clean and includes a specific test case that correctly validates the new logic.

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 4 additional findings.

Open in Devin Review

@cruzdanilo
Copy link
Copy Markdown
Member Author

@claude review

@sentry
Copy link
Copy Markdown

sentry bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.32%. Comparing base (3645e99) to head (12a4f4c).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #741      +/-   ##
==========================================
+ Coverage   67.23%   67.32%   +0.09%     
==========================================
  Files         206      206              
  Lines        6913     6914       +1     
  Branches     2155     2156       +1     
==========================================
+ Hits         4648     4655       +7     
+ Misses       2078     2075       -3     
+ Partials      187      184       -3     
Flag Coverage Δ
e2e 67.28% <33.33%> (+15.27%) ⬆️

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: 2

🤖 Fix all issues with AI agents
In `@server/hooks/block.ts`:
- Around line 357-361: The fingerprinting branch in server/hooks/block.ts that
checks for a WrappedError currently assumes error.cause.data.args[1] exists;
update the logic in that expression (where BaseError and
ContractFunctionRevertedError are checked and error.cause.data?.errorName ===
"WrappedError") to defensively verify Array.isArray(error.cause.data.args) and
error.cause.data.args.length > 1 before using args[1], and fall back to a safe
string (e.g., "undefined" or the existing fallback chain) if the check fails so
you never coerce an actual undefined into the fingerprint.

In `@server/test/hooks/block.test.ts`:
- Around line 273-284: The WrappedError ABI (the const ABI array with type
"error" and name "WrappedError") is duplicated; extract it into a single
exported constant (e.g., WRAPPED_ERROR_ABI) in a shared module, export it, and
replace the local ABI definitions in both the test and the block hook with an
import of that constant, preserving the "as const" typing and the exact
structure so both places use the same source of truth.

@cruzdanilo cruzdanilo merged commit 12a4f4c into main Feb 7, 2026
15 checks passed
@cruzdanilo cruzdanilo deleted the decode branch February 7, 2026 21:26
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