Skip to content

fix(request_handler): preserve falsy non-None request bodies - #171

Merged
tharropoulos merged 1 commit into
typesense:masterfrom
abhirajadhikary06:fix/empty-request-body
Nov 27, 2026
Merged

tharropoulos merged 1 commit into
typesense:masterfrom
abhirajadhikary06:fix/empty-request-body

Conversation

@abhirajadhikary06

@abhirajadhikary06 abhirajadhikary06 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #170

Summary

Fixes RequestHandler.build_request_kwargs() silently dropping falsy non-None request bodies such as {}, "", and b"".

Changes

  • Update RequestHandler.build_request_kwargs in src/typesense/request_handler.py to check (body := kwargs.get("data")) is not None instead of relying on truthiness.
  • Add unit tests in tests/api_call_test.py covering {}, "", b"", and None bodies as well as ApiCall.post(..., body={}).

Testing

  • Verified py_compile on modified files.
  • Verified RequestHandler.build_request_kwargs and ApiCall.post via httpx.MockTransport for {}, "", b"", and None.
  • Please run the full CI suite (run-unasync.py --check, ruff, mypy, and pytest).

@abhirajadhikary06

Copy link
Copy Markdown
Contributor Author

@tharropoulos @haydenhoang can you review this ?

@tharropoulos
tharropoulos merged commit a7fa5e9 into typesense:master Nov 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RequestHandler.build_request_kwargs drops empty request bodies such as {} or ""

2 participants