Skip to content

Inconsistent Handling of Revert Data in Error Objects #4954

Open
@web3skeptic

Description

@web3skeptic

Ethers Version

6.13.2

Search Terms

No response

Describe the Problem

Inconsistent Handling of Revert Data in Error Objects

Description

With help of provider.on("debug") hooks, I've tracked inconsistent error object structures when transactions revert. The same transaction can sometimes return proper execution revert data and other times return "missing revert data" error without the "execution reverted" message, making it difficult to reliably extract revert reasons.

Observed Behavior

For the exact same transaction input, I sometimes receive:

  1. Case 1 (Missing "execution reverted" message):
{
    "action": "receiveEip1193Error",
    "error": {
        "code": -32603,
        "data": {
            "code": -32015,
            "message": "0xe237d92200000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a4000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b",
            "cause": null
        },
        "payload": {
            "method": "eth_estimateGas",
            "params": [
                {
                    "value": "0x0",
                    "from": "0x40c8e83414dca470b8bad8a46c91837b80f960a4",
                    "to": "0xc12c1e50abb450d6205ea2c3fa861b3b834d13e8",
                    "data": "0x0d22d9b50000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000700000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a400000000000000000000000057928fb15ffb7303b65edc326dc4dc38150008e1000000000000000000000000742b7dbb0f1d330a83497df79075ebc778e6e698000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b000000000000000000000000c7d3df890952a327af94d5ba6fdc1bf145188a1b000000000000000000000000dca9d42a96ecf8ede1e6920bec08870bba69600e000000000000000000000000e8fc7a2d0573e5164597b05f14fa9a7fca7b215c000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000db04426ea7dc73700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000db04426ea7dc737000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000040001000400030002000300050001000400060002000600050000"
                }
            ]
        }
    }
}
  1. Case 2 (Proper error structure):
{
    "action": "receiveEip1193Error",
    "error": {
        "code": -32603,
        "data": {
            "code": 3,
            "message": "execution reverted",
            "data": "0xe237d92200000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a4000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b",
            "cause": null
        },
        "payload": {
            "method": "eth_estimateGas",
            "params": [
                {
                    "value": "0x0",
                    "from": "0x40c8e83414dca470b8bad8a46c91837b80f960a4",
                    "to": "0xc12c1e50abb450d6205ea2c3fa861b3b834d13e8",
                    "data": "0x0d22d9b50000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000700000000000000000000000040c8e83414dca470b8bad8a46c91837b80f960a400000000000000000000000057928fb15ffb7303b65edc326dc4dc38150008e1000000000000000000000000742b7dbb0f1d330a83497df79075ebc778e6e698000000000000000000000000b604ccd343cdf254e100f206d903d6975ea2950b000000000000000000000000c7d3df890952a327af94d5ba6fdc1bf145188a1b000000000000000000000000dca9d42a96ecf8ede1e6920bec08870bba69600e000000000000000000000000e8fc7a2d0573e5164597b05f14fa9a7fca7b215c000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000030728cbce638c900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000db04426ea7dc73700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000db04426ea7dc737000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000040001000400030002000300050001000400060002000600050000"
                }
            ]
        }
    }
}

Key Differences

Property Case 1 (Problematic) Case 2 (Expected)
error.data.code -32015 3
error.data.message Contains raw revert data "execution reverted"
error.data.data Missing Contains raw revert data

Impact

This inconsistency makes it difficult to build reliable error handling logic, because the getBuiltinCallException function logic

let message = "missing revert data";
does not passes the message to the application level.

Environment

  • ethers.js version: 6.13.2
  • Network: GnosisChain
  • Provider type: Brwoser Metamask extension

Steps to Reproduce

  1. Set up a debug hook:
provider.on("debug", (info) => {
    console.log("DEBUG:", info);
});
  1. Attempt to create a transaction which should fail and cause the revert
const txResponse = await signer.sendTransaction(tx);
  1. The exact steps to reproduce the issue was not identified, run the same code multiple times to observe the inconsistent error structures.

Environment

Browser (Chrome, Safari, etc)

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

investigateUnder investigation and may be a bug.next-patchIssues scheduled for the next arch release.on-deckThis Enhancement or Bug is currently being worked on.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions