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

Open Beginner friendly
#170 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@abhirajadhikary06 is already working on this.

Since Nov 27, 2026.

  • #171 by @abhirajadhikary06 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api

Research direction

Start with RequestHandler.build_request_kwargs() and trace how its data argument becomes the outgoing request content. Check the existing tests for request body handling and add coverage for {}, "", b"", and None; done means falsy non-None bodies are preserved while None still omits content.

Written by the indexing model from the issue text.

Description

Description

RequestHandler.build_request_kwargs() checks the truthiness of kwargs.get("data") rather than checking is not None. As a result, valid falsy request bodies like {} (for example, client.analytics.events.flush() passes body={}), "", or b"" are silently omitted from the request.

Steps to Reproduce
request_kwargs = request_handler.build_request_kwargs(data={})
# "content" is missing instead of "{}"
Actual Behavior

if body := kwargs.get("data"): evaluates to False for {}, "", and b"", so request_kwargs["content"] is never set and no body is sent.

Expected Behavior

Check if (body := kwargs.get("data")) is not None: so {} is serialized to "{}" and ""/b"" are preserved, while None (or omitted data) still omits content.

Dominant language
Python
Stars
247
Forks
69
Avg merge
19h 4m
Merged PRs (30d)
9

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from typesense/typesense-python

All issues in typesense/typesense-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.