You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Money risk.buy_max_cost=True slips through as integer 1 (= 1 cent cap), matching the exact failure mode #225 closed for DollarDecimal/FixedPointCount where bool was rejected because it is an int subclass.
A caller who accidentally passes a flag (risk_check_passed, dry_run) where cents were expected places an order capped at $0.01 with no error.
@field_validator("buy_max_cost", mode="before")@classmethoddef_reject_decimal_and_float_buy_max_cost(cls, v: object) ->object:
...
ifisinstance(v, Decimal):
raiseValueError(...)
ifisinstance(v, float):
raiseValueError("buy_max_cost must be int (cents), not float...")
returnv# bool falls through here
Recommended fix
Add if isinstance(v, bool): raise ValueError("buy_max_cost must be int (cents), not bool — bool is an int subclass.") ahead of the int passthrough, mirroring _coerce_decimal. Add a regression test that asserts CreateOrderRequest(buy_max_cost=True, ...) raises.
Activity
fix(orders): reject bool in CreateOrderRequest.buy_max_cost validator
fix(models): reject bool on int request fields (subaccount routing, t…
fix(models): reject bool on int request fields (subaccount routing, t…
fix(models): reject bool on int request fields (#295) (#305)
deps: bump pydantic floor to >=2.4 for money-safety invariants (#346) (…