Skip to content

Python SDK doesn't export hosted-trading error classes from the top-level package, unlike the TypeScript SDK #1820

Description

@realfishsam

Gap

The TypeScript SDK re-exports its entire hosted-trading error module from the package root, so every hosted error class is directly importable. The Python SDK's top-level __init__.py has zero references to the hosted error module or any of its classes — they're only reachable through a lazy module.__getattr__ fallback in errors.py, or by reaching into the underscore-prefixed private module directly. This is the same class of gap as issue #1804 (NotSupported not exported from Python's top level), but for the entire hosted-error family (HostedTradingError + 9 leaf classes) rather than a single base error.

Core

Not a core/src gap — this is a hosted-trading-service error taxonomy that both SDKs independently implement client-side to classify trade.pmxt.dev error responses (per docs/api-reference/errors.mdx). Referenced here as the shared contract both SDKs are expected to expose identically.

TypeScript SDK

sdks/typescript/index.ts:51: export * from "./pmxt/hosted-errors.js"; — a wildcard re-export making every class in sdks/typescript/pmxt/hosted-errors.ts directly importable from the package root: HostedTradingError (line 23), InsufficientEscrowBalance (44), OrderSizeTooSmall (57), InvalidApiKey (70), OutcomeNotFound (83), CatalogUnavailable (96), BuiltOrderExpired (109), InvalidSignature (122), NoLiquidity (135), MissingWalletAddress (152). E.g. import { InsufficientEscrowBalance } from 'pmxtjs' works.

Python SDK

sdks/python/pmxt/__init__.pygrep -n "Hosted\|hosted_errors\|InsufficientEscrowBalance" sdks/python/pmxt/__init__.py returns nothing; none of the 10 classes defined in sdks/python/pmxt/_hosted_errors.py (HostedTradingError line 24, InsufficientEscrowBalance 43, OrderSizeTooSmall 50, InvalidApiKey 57, OutcomeNotFound 64, CatalogUnavailable 71, BuiltOrderExpired 79, InvalidSignature 86, NoLiquidity 93, MissingWalletAddress 100) are imported or re-exported from the package root. They're reachable only via sdks/python/pmxt/errors.py:193-197's module-level __getattr__, which lazily proxies attribute lookups to _hosted_errors (i.e. pmxt.errors.InsufficientEscrowBalance works, but only because of dynamic fallback, and only via the errors submodule — not import pmxt; pmxt.InsufficientEscrowBalance), or by importing the private _hosted_errors module directly.

Evidence

export * from "./pmxt/hosted-errors.js" in sdks/typescript/index.ts:51 vs. no corresponding import/re-export anywhere in sdks/python/pmxt/__init__.py. Confirmed by grepping both files for the hosted error class names.

Impact

TypeScript users can import { InsufficientEscrowBalance } from 'pmxtjs' directly, matching the pattern in docs/api-reference/errors.mdx's TS code samples. Python users following the equivalent Python code sample in the same doc (except InsufficientEscrowBalance:) must know to import from pmxt.errors (relying on undocumented lazy __getattr__ behavior) or pmxt._hosted_errors (a private module) instead of the top-level pmxt package — an inconsistent, harder-to-discover import path for the exact same error-handling pattern the docs present as identical across both SDKs.


Found by automated Core-to-SDK surface coverage audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions