Problem
The bytes-fast-path sibling _delete_with_body_json accepts a params: dict[str, Any] | None = None kwarg; the dict-based _delete_with_body does not, and silently drops any query params if a caller tries to add one. Both helpers exist for the same DELETE-with-body shape, so the asymmetry is purely accidental. AsyncResource mirrors the same gap.
Concrete consequence: batch_cancel_v2 currently uses _delete_with_body; if the spec ever adds a query param to /portfolio/events/orders/batched (subaccount default, exchange_index, etc.), the implementation can't route it without first plumbing params through. Tightening the helper now prevents the next contributor from re-introducing the gap.
Evidence
kalshi/resources/_base.py:256-273 (SyncResource._delete_with_body, no params):
def _delete_with_body(
self,
path: str,
*,
json: dict[str, Any],
extra_headers: dict[str, str] | None = None,
) -> dict[str, Any] | None:
response = self._transport.request(
"DELETE",
path,
json=json,
headers={"Content-Type": "application/json"},
extra_headers=extra_headers,
)
kalshi/resources/_base.py:275-295 (_delete_with_body_json — accepts params):
def _delete_with_body_json(
self,
path: str,
*,
content: bytes,
params: dict[str, Any] | None = None,
extra_headers: dict[str, str] | None = None,
) -> dict[str, Any] | None:
response = self._transport.request(
"DELETE",
path,
params=params,
content=content,
...
)
AsyncResource has the same asymmetric pair.
Suggested fix
Add params: dict[str, Any] | None = None to both SyncResource._delete_with_body and AsyncResource._delete_with_body, threading it into self._transport.request(..., params=params, ...). No public-API change; no caller change required today.
Source
Round-3 independent audit (reviewer: resources_api).
Problem
The bytes-fast-path sibling
_delete_with_body_jsonaccepts aparams: dict[str, Any] | None = Nonekwarg; the dict-based_delete_with_bodydoes not, and silently drops any query params if a caller tries to add one. Both helpers exist for the same DELETE-with-body shape, so the asymmetry is purely accidental.AsyncResourcemirrors the same gap.Concrete consequence:
batch_cancel_v2currently uses_delete_with_body; if the spec ever adds a query param to/portfolio/events/orders/batched(subaccount default, exchange_index, etc.), the implementation can't route it without first plumbingparamsthrough. Tightening the helper now prevents the next contributor from re-introducing the gap.Evidence
kalshi/resources/_base.py:256-273(SyncResource._delete_with_body, noparams):kalshi/resources/_base.py:275-295(_delete_with_body_json— acceptsparams):AsyncResourcehas the same asymmetric pair.Suggested fix
Add
params: dict[str, Any] | None = Noneto bothSyncResource._delete_with_bodyandAsyncResource._delete_with_body, threading it intoself._transport.request(..., params=params, ...). No public-API change; no caller change required today.Source
Round-3 independent audit (reviewer:
resources_api).