Skip to content

SDK drift: TypeScript PmxtError sets this.name = constructor.name for subclass identification; Python PmxtError has no equivalent .name attribute #1616

Description

@realfishsam

Drift

TypeScript's PmxtError base class follows the standard JS Error idiom of setting this.name to the concrete subclass name in the constructor, so every error instance carries a .name property identifying its specific error class (e.g. "BadRequest", "OrderNotFound"). Python's PmxtError has no equivalent attribute — there is no self.name assignment anywhere in errors.py. A Python caller who wants the class name at runtime must use type(err).__name__ instead of a first-class attribute.

TypeScript SDK

sdks/typescript/pmxt/errors.ts:8-29 (PmxtError class), specifically line 20:

export class PmxtError extends Error {
    ...
    constructor(message: string, code: string = "UNKNOWN_ERROR", retryable: boolean = false, exchange?: string) {
        super(message);
        this.name = this.constructor.name;
        ...
    }
    ...
}

Every subclass (BadRequest, AuthenticationError, OrderNotFound, etc.) inherits this behavior via super(...), so err.name always equals the concrete subclass name at runtime — e.g. new OrderNotFound(...).name === "OrderNotFound".

Python SDK

sdks/python/pmxt/errors.py:13-27 (PmxtError class):

class PmxtError(Exception):
    ...
    def __init__(self, message: str, code: str = "UNKNOWN_ERROR", retryable: bool = False, exchange: str | None = None) -> None:
        ...
    def __str__(self) -> str:
        parts = [self.message]
        if self.exchange:
            parts.append(f"[{self.exchange}]")
        return " ".join(parts)

No self.name (or any equivalent) is ever assigned in __init__, and no subclass in errors.py sets one either (confirmed via grep — zero matches for self.name anywhere in the file). A Python PmxtError instance has no .name attribute at all; accessing err.name raises AttributeError.

Expected

Both SDKs should expose the same error-identification surface. Python's PmxtError.__init__ should set self.name = type(self).__name__ (or equivalent) so that err.name works identically in both languages, matching the documented cross-SDK error contract implied by the shared ERROR_CODE_MAP/_ERROR_CODE_MAP tables.

Impact

Code ported from TypeScript that does if err.name == "OrderNotFound": (a common idiomatic pattern for identifying a specific error subclass without importing every class) will raise AttributeError: 'OrderNotFound' object has no attribute 'name' in Python instead of behaving analogously. Logging/telemetry code that reads err.name for structured error reporting will also break silently when ported between the two SDKs.


Found by automated SDK cross-language drift audit

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