Skip to content

_delete_with_body lacks a params kwarg that _delete_with_body_json already accepts #340

Description

@TexasCoding

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    polishCode-quality and DX improvements; non-functional

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions