Querystring drops explicit empty-string scalar values

Open Beginner friendly
#3,837 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start at Querystring.stringify() and _stringify_item(), using the reproduction in the issue to trace how scalar values are serialized. Verify that None remains omitted while an explicit empty string produces filter=, including the array formats mentioned in the issue.

Written by the indexing model from the issue text.

Description

v4

Querystring.stringify() drops an explicit empty-string scalar because _stringify_item() checks the serialized value with a truthiness test.

stringify({"filter": ""}) == ""  # current behavior

This conflates an explicit empty value with None. In a URL query, filter= is distinct from omitting filter entirely. The behavior is also inconsistent across array formats, where an empty string can be retained by comma serialization.

Expected behavior: continue omitting None, but serialize an explicit empty string as filter=.

Dominant language
Python
Stars
31.7k
Forks
5.8k
Avg merge
1d 6h
Merged PRs (30d)
96

Contributor guide

Open the contributing guide

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 openai/openai-python

All issues in openai/openai-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.