Skip to content

fix: handle empty string cookie values correctly#7128

Open
shindonghwi wants to merge 1 commit intopsf:mainfrom
shindonghwi:fix/empty-cookie-value
Open

fix: handle empty string cookie values correctly#7128
shindonghwi wants to merge 1 commit intopsf:mainfrom
shindonghwi:fix/empty-cookie-value

Conversation

@shindonghwi
Copy link

_find_no_duplicates() was checking if toReturn: which treats empty string as falsy.

This causes KeyError when retrieving a cookie with an empty string value:

jar = RequestsCookieJar() jar.set("empty", "") jar["empty"] # KeyError!

Fixed by checking if toReturn is not None: instead.

Added test case.

_find_no_duplicates() was using 'if toReturn:' which treats empty string as falsy, causing KeyError when retrieving cookies with empty string values. Changed to 'if toReturn is not None:' to properly handle this case.
@shindonghwi shindonghwi reopened this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant