Skip to content

SDK drift: fetchMatchedMarketClusters/fetchMatchedEventClusters prefer marketId/eventId over slug in TypeScript but slug over marketId/eventId in Python — and TypeScript is inconsistent with its own sibling fetchMarketMatches #1534

Description

@realfishsam

Drift

Given a UnifiedMarket/UnifiedEvent object with both an ID and a slug populated, fetchMatchedMarketClusters/fetchMatchedEventClusters derive the query key with opposite preference in each language — and TypeScript's own preference here contradicts its sibling method fetchMarketMatches.

TypeScript SDK

sdks/typescript/pmxt/router.ts:394-396 (fetchMatchedMarketClusters):

const marketId = params.marketId ?? params.market?.marketId;
const slug = params.slug ?? (!marketId ? params.market?.slug : undefined);

marketId is computed first and always taken from params.market.marketId if present; slug is only pulled from params.market.slug when no marketId exists. Same pattern for events at router.ts:427-429.

Contrast with the sibling fetchMarketMatches, sdks/typescript/pmxt/router.ts:259:

const marketId = params.marketId ?? (!params.market?.slug ? params.market?.marketId : undefined);

Here slug is preferred — marketId is only pulled from params.market.marketId when no slug exists.

Python SDK

sdks/python/pmxt/router.py:352-356 (fetch_matched_market_clusters):

if market is not None and market_id is None:
    if hasattr(market, "slug") and market.slug:
        slug = slug or market.slug
    else:
        market_id = market.market_id

Prefers slug over market_id, matching fetch_market_matches's own preference. Same for events at router.py:407-411.

Expected

TypeScript's fetchMatchedMarketClusters/fetchMatchedEventClusters should prefer slug over marketId/eventId, matching both Python's behavior and TypeScript's own fetchMarketMatches.

Impact

Passing the same UnifiedMarket/UnifiedEvent object (with both an ID and slug populated) into fetchMatchedMarketClusters/fetchMatchedEventClusters yields a marketId/eventId-keyed query in TypeScript but a slug-keyed query in Python — potentially different cluster results if the backend's ID and slug indexes aren't perfectly synchronized. TypeScript additionally contradicts itself between fetchMarketMatches and fetchMatchedMarketClusters for the identical input shape.


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