Skip to content

spec-drift [suibets] MEDIUM: SuibetsRawOffer.id interface still typed as string despite type guard accepting number — residual from incomplete #1868 fix #2130

Description

@realfishsam

Exchange

suibets

Drift Type

CHANGED_RESPONSE (residual from partial fix)

Severity

MEDIUM — string methods called on id (e.g. .replace(), .includes()) will throw a TypeError at runtime when the API returns a numeric id

Their Docs

Suibets P2P API returns id as a number (not a string) for offers — per the live API change tracked in #1868.

Our Cached Spec

No core/specs/suibets/ YAML exists. core/src/exchanges/suibets/api.ts is a documentation-only file (NOT wired into defineImplicitApi()).

Current State (discovered by code audit, 2026-08-23)

Issue #1868 was partially fixed: isSuibetsRawOffer() in fetcher.ts lines 64–72 now accepts both string and number for id:

return (
    (typeof v['id'] === 'string' || typeof v['id'] === 'number') &&
    typeof v['creatorOdds'] === 'number' &&
    typeof v['creatorStake'] === 'number'
);

However, the SuibetsRawOffer interface at fetcher.ts:6 still declares:

id: string

This type inconsistency means:

  • The type guard admits number ids at runtime (correct behaviour)
  • But raw.id downstream is still typed as string — TypeScript sees it as string
  • Any code calling raw.id.replace(...), raw.id.slice(...), or other string methods will receive a TypeError at runtime when id is a number, without any compile-time warning

callApi() References at Risk

None — suibets fetcher uses no callApi().

Hardcoded URL Bypasses

All Suibets HTTP calls use this.get<T>()ctx.http.get() directly.

Impact

Fix Required

Update fetcher.ts line ~6: change id: string to id: string | number in the SuibetsRawOffer interface.


Found by automated spec drift audit — 2026-08-23

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