Skip to content

SDK drift: hosted error subclasses have different .code values in TypeScript (inherits parent code) vs Python (sets DEFAULT_CODE) #1423

Description

@realfishsam

Summary

Python hosted error classes in sdks/python/pmxt/_hosted_errors.py each define a DEFAULT_CODE class variable that is used as the PmxtError.code. TypeScript hosted error classes in sdks/typescript/pmxt/hosted-errors.ts do NOT set an explicit code — they inherit the code from their parent error class (e.g., InvalidOrder, InsufficientFunds), which is a completely different value.

This means e.code returns systematically different strings between the two SDKs for every hosted error subclass.

Complete mismatch table

Error class TypeScript .code (inherited from parent) Python .code (DEFAULT_CODE)
HostedTradingError "UNKNOWN_ERROR" (base PmxtError default — hosted-errors.ts:37 calls super(detail)) "HOSTED_TRADING_ERROR" (_hosted_errors.py:27)
InsufficientEscrowBalance "INSUFFICIENT_FUNDS" (inherits InsufficientFundshosted-errors.ts:44) "INSUFFICIENT_ESCROW_BALANCE" (_hosted_errors.py:46)
OrderSizeTooSmall "INVALID_ORDER" (inherits InvalidOrderhosted-errors.ts:57) "ORDER_SIZE_TOO_SMALL" (_hosted_errors.py:53)
InvalidApiKey "AUTHENTICATION_ERROR" (inherits AuthenticationErrorhosted-errors.ts:70) "INVALID_API_KEY" (_hosted_errors.py:58)
OutcomeNotFound "NOT_FOUND" (inherits NotFoundErrorhosted-errors.ts:83) "OUTCOME_NOT_FOUND" (_hosted_errors.py:63)
CatalogUnavailable "EXCHANGE_NOT_AVAILABLE" (inherits ExchangeNotAvailablehosted-errors.ts:96) "CATALOG_UNAVAILABLE" (_hosted_errors.py:71)
BuiltOrderExpired "INVALID_ORDER" (inherits InvalidOrderhosted-errors.ts:109) "BUILT_ORDER_EXPIRED" (_hosted_errors.py:79)
InvalidSignature "AUTHENTICATION_ERROR" (inherits AuthenticationErrorhosted-errors.ts:122) "INVALID_SIGNATURE" (_hosted_errors.py:86)
NoLiquidity "INVALID_ORDER" (inherits InvalidOrderhosted-errors.ts:135) "NO_LIQUIDITY" (_hosted_errors.py:93)

File locations

  • TypeScript: sdks/typescript/pmxt/hosted-errors.ts (lines 36–156)
  • Python: sdks/python/pmxt/_hosted_errors.py (lines 27–97)

Impact

  • Error-handling code that switches on e.code to identify specific hosted failures will behave differently in each SDK.
  • TypeScript collapses multiple distinct failures into the same parent code (e.g., OrderSizeTooSmall and NoLiquidity both produce "INVALID_ORDER"), making granular programmatic handling impossible in TypeScript using the code property.
  • Logging/monitoring systems that emit e.code will see incompatible values across SDKs for the same upstream error.

Metadata

Metadata

Assignees

No one assigned

    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