requests icon indicating copy to clipboard operation
requests copied to clipboard

Fix: Ensure empty lists in params are encoded as empty keys #6557

Open amritamishra01 opened this issue 1 month ago • 0 comments

Fixes #6557

Summary Previously, passing an empty list as a query parameter value (e.g., params={'key': []}) caused the key to be silently dropped from the URL. This behavior was inconsistent with empty strings (params={'key': ''}), which correctly produce ?key=.

Changes

  • Modified parameter encoding logic in models.py to treat empty lists as a list containing a single empty string [''].
  • Verified that ?key= is generated, matching the behavior of empty strings.

Tests

  • Added regression test test_params_with_empty_list_are_included in tests/test_requests.py.
  • Verified locally with pytest.

amritamishra01 avatar Nov 23 '25 19:11 amritamishra01