Skip to content

SDK drift: verifySignature/verify_signature drops the underlying exception message in Python for two failure paths that TypeScript includes verbatim #1904

Description

@realfishsam

Drift

When EIP-712 signature verification fails because the signing library is missing, or because typed-data recovery itself throws, TypeScript's InvalidSignature message includes the underlying exception's message text. Python's equivalent raises InvalidSignature with a static string and only preserves the original exception via from exc (traceback chaining), which is not part of the exception's own message/str().

TypeScript SDK

sdks/typescript/pmxt/hosted-typed-data.ts:641-667 (verifySignature):

let ethers: any;
try {
    ethers = loadEthers("ethers is required for hosted signature verification");
} catch (err) {
    throw new InvalidSignature(
        0,
        err instanceof Error ? err.message : "ethers is required for hosted signature verification",
    );
}
...
} catch (exc) {
    throw new InvalidSignature(
        0,
        `signature recovery failed: ${(exc as Error).message}`,
    );
}

Both catch blocks interpolate the caught error's .message into the thrown InvalidSignature's detail text.

Python SDK

sdks/python/pmxt/_hosted_typeddata.py:310-320 (verify_signature):

try:
    from eth_account import Account
    from eth_account.messages import encode_typed_data
except ImportError as exc:
    raise InvalidSignature("eth-account is required for hosted signature verification") from exc

try:
    signable = encode_typed_data(full_message=typed_data)
    recovered = Account.recover_message(signable, signature=normalized)
except Exception as exc:
    raise InvalidSignature("signature recovery failed") from exc

Both messages are static string literals; str(exc) is never appended, so the caller-visible InvalidSignature.detail/message never contains the underlying library error (only visible via the Python traceback's chained cause, not via str(error)).

Expected

Both SDKs should surface the same level of diagnostic detail for the same failure. Either TypeScript should stop appending the underlying message (matching Python's generic text), or Python should interpolate str(exc) into the raised message (matching TypeScript).

Impact

A caller catching InvalidSignature and logging/displaying str(error) gets a specific, actionable underlying-library error in TypeScript (e.g. the real ethers.js recovery failure reason) but only a generic, undifferentiated message in Python — makes Python-side signature-verification failures harder to diagnose from the exception alone.


Found by automated SDK cross-language drift audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    sdk-driftCross-language SDK consistency findings (TypeScript vs Python)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions