Skip to content

SDK drift: missing-signing-dependency error is a different, non-PmxtError type in each language (Error vs ImportError) #1532

Description

@realfishsam

Drift

When the optional signing dependency (ethers in TypeScript, eth-account in Python) isn't installed, each SDK raises a different generic error type — and neither is PmxtError, so the two languages are also inconsistent with each other.

TypeScript SDK

sdks/typescript/pmxt/signers.ts:44-61 (loadEthers):

export function loadEthers(installHint: string = ETHERS_INSTALL_HINT): any {
    if (typeof require === "function") {
        try {
            return require("ethers");
        } catch {
            throw new Error(installHint);
        }
    }
    ...
    if (!req) throw new Error(installHint);
    try {
        return req("ethers");
    } catch {
        throw new Error(installHint);
    }
}

Throws a plain JS Error, not PmxtError.

Python SDK

sdks/python/pmxt/signers.py:24-33 (_load_eth_account):

def _load_eth_account() -> tuple[Any, Any]:
    try:
        from eth_account import Account
        from eth_account.messages import encode_typed_data
    except ImportError as exc:
        raise ImportError(
            "Hosted PMXT signing requires the optional eth-account dependency. "
            f"Install it with: {_ETH_ACCOUNT_INSTALL_HINT}."
        ) from exc
    return Account, encode_typed_data

Raises a built-in ImportError, not PmxtError.

Expected

Both SDKs should raise the same typed SDK error (e.g. a PmxtError subclass) for a missing optional signing dependency, so the failure is catchable through the SDK's normal error-handling surface.

Impact

Code written to catch PmxtError for "hosted signing unavailable" misses this condition in both SDKs, but in mutually incompatible ways: TypeScript callers must catch a generic Error, Python callers must specifically catch ImportError. Neither matches the other, and neither integrates with the SDK's typed error hierarchy. Not covered by already-filed #1438 (which only addresses the visibility/reusability of loadEthers, not its error type).


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

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions