Repository navigation
Description
Problem
v2.5 narrowed CreateOrderRequest.side / .action (and related fixed-enum fields) to their Literal aliases so a typo like side="yess" fails at construction. AmendOrderRequest was left at bare str, even though amend has the same money-routing surface (price/count change on an open order) and the same enum constraints in the spec.
A caller building an amend body directly — AmendOrderRequest(ticker="X", side="yess", action="buy", count=Decimal(1)) — constructs without error, the SDK signs the request, the server rejects with 400. Same fail-fast argument that drove v2.5; same fix.
Evidence
kalshi/models/orders.py:17-21— Literal aliases exist:
SideLiteral = Literal["yes", "no"]
ActionLiteral = Literal["buy", "sell"]kalshi/models/orders.py:173-175—CreateOrderRequestuses the narrowed types:
ticker: str
side: SideLiteral
action: ActionLiteralkalshi/models/orders.py:252-254—AmendOrderRequeststill barestr:
ticker: str
side: str
action: str-
kalshi/models/orders.py:14-16— the stale top-of-file comment ("Pydantic request models leave these fields asstrto remain tolerant of spec drift") now applies only toAmendOrderRequestby accident;CreateOrderRequestandCreateOrderV2Request(lines 471-477) have already been narrowed. -
CHANGELOG.md:270-272— v2.5 closure: "V1CreateOrderRequestenum-style fields narrowed toLiteral[...](Polish bundle: model small items (AwareDatetime in WS, V1 Literal, default=None, timestamp typing, Decimal NaN) #270). Closes the V1/V2 strictness gap."AmendOrderRequestis not mentioned.
Suggested fix
In kalshi/models/orders.py, change side: str → side: SideLiteral and action: str → action: ActionLiteral on AmendOrderRequest. Update or remove the stale module-level comment at lines 13-16 since both V1 and V2 create paths are already narrowed. Add a regression test mirroring the v2.5 CreateOrderRequest test asserting AmendOrderRequest(ticker="X", side="yess", action="buy", count=Decimal(1)) raises ValidationError on side.
Source
Round-3 independent audit (reviewer: models_contracts+resources_api).
Activity
polish(tests): update amend validation tests for AmendOrderRequest Li…
fix(models): AmendOrderRequest Literal narrowing + V1 ge=0 + create()…
release: 2.7.0 — post-v2.6 independent multi-LLM reviewer SDK audit c…