Skip to content

Return an empty list for an empty query string - #926

Merged
azmeuk merged 1 commit into
authlib:mainfrom
RavSinghChandan:extract-params-empty-string
Oct 14, 2026
Merged

azmeuk merged 1 commit into
authlib:mainfrom
RavSinghChandan:extract-params-empty-string

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

extract_params documents that empty strings, dicts and lists all give back an empty list of parameters:

>>> extract_params("")
None      # documented as []
>>> extract_params({})
[]
>>> extract_params([])
[]

The dict and list cases do. The empty string falls through to a truthiness guard and returns None instead.

url_decode("") already returns [], so the guard only needed to be about the type rather than the value. Every caller inside authlib writes extract_params(body) or [], which works either way.

Reverting the change fails the three new tests

extract_params documents that empty strings, dicts and lists all give back an
empty list of parameters. The dict and list cases do; the empty string fell
through to a truthiness guard and returned None instead.

url_decode already returns [] for an empty string, so the guard only needed to
be about the type rather than the value. Every caller inside authlib writes
extract_params(body) or [], which works either way.
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Hi, just checking in on this one. It's still mergeable and the tests pass. Happy to change anything if needed.

@azmeuk
azmeuk merged commit 5b9c2bb into authlib:main Oct 14, 2026
9 checks passed
@azmeuk

azmeuk commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants