Commit 61fedc6
authored
Nightly integration test `test_transfer_between_subaccounts` failed with:
pydantic_core._pydantic_core.ValidationError: 1 validation error for
ApplySubaccountTransferRequest
to_subaccount
Input should be less than or equal to 32 [type=less_than_equal,
input_value=41, input_type=int]
Root cause
----------
The demo server created an ephemeral subaccount and returned
`subaccount_number=41`. The test then tried to use that value as
`to_subaccount` in a transfer, but the SDK refused client-side because
7 request-side model fields carried `le=32`.
The `le=32` bound was added in v0.11.0 from a code-review pass that
read the spec's prose description ("0 for primary, 1-32 for numbered
subaccounts") as a hard limit. The actual OpenAPI schema defines no
`minimum`/`maximum` constraints on any of these fields. Demo has
clearly extended past 32 in practice, and response-side subaccount
numbers were already unbounded — the asymmetry was the bug.
Fix
---
Drop `le=32` from 7 request-side model fields, keep `ge=0`:
ApplySubaccountTransferRequest.{from,to}_subaccount
UpdateSubaccountNettingRequest.subaccount_number
CreateOrderRequest.subaccount
BatchCancelOrdersV2RequestOrder.subaccount
CreateRFQRequest.subaccount
CreateQuoteRequest.subaccount
Server is the source of truth on the upper bound. Negative values
still fail-fast at the SDK boundary; out-of-range positives now
round-trip cleanly.
Docstrings on ApplySubaccountTransferRequest and SubaccountsResource
updated to drop the "1-32" claim and explain the constraint asymmetry.
Tests
-----
Replaced `test_transfer_request_rejects_out_of_range_subaccount`
(asserted `to_subaccount=33` failed) with
`test_transfer_request_accepts_subaccount_above_32` (asserts `41`
round-trips). The existing
`test_transfer_request_rejects_negative_subaccount` keeps the `ge=0`
coverage; the new test locks in the new contract so a future code-
review pass can't re-introduce the bound from prose alone.
Verification
------------
uv run pytest tests/test_subaccounts.py -> 43 passed
uv run pytest tests/ --ignore=tests/integration
-> 2023 passed (unchanged)
uv run mypy kalshi/ -> Success
uv run ruff check . -> All checks passed
The failing integration test cannot be reproduced locally without
hitting demo with KALSHI_KEY_ID, but the unit-test regression guard
(`accepts_subaccount_above_32`) directly mirrors the failure mode
from the nightly run.
Closes #164.
1 parent 8f98e63 commit 61fedc6
6 files changed
Lines changed: 48 additions & 19 deletions
File tree
- kalshi
- models
- resources
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
| 560 | + | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
31 | | - | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | | - | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
202 | 208 | | |
203 | 209 | | |
204 | 210 | | |
| |||
0 commit comments