RequestsCookieJar._find_on_duplicates wrongly fails on cookie with empty value
@Vatmuri2 is already working on this.
Since May 23, 2026.
- #7246 by @darkoss1 — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 58/100
Research direction
Start in cookies.py at RequestsCookieJar._find_no_duplicates and reproduce the failure with the IPython example from the issue. Verify the empty-value cookie lookup returns an empty string rather than raising KeyError, and check the existing cookie behavior around this method before considering the change complete.
Written by the indexing model from the issue text.
Description
Getting the value of a cookie which is set without a value by a website raises a KeyError. I don't know if this is by design. Browsers seem to accept these kind of cookies, even though this behaviour seems like bad practice.
Expected Result
An empty string.
Actual Result
RequestsCookieJar._find_no_duplicates raises a KeyError
Reproduction Steps
In ipython:
import requests
resp = requests.get("https://www.pib-insurance.com/")
resp.cookies.get_dict() # pretty print cookies
resp.cookies["firstname"]
Fix
I think last if in _find_no_duplicates (line 397 of cookies.py) should be if toReturn is not None: to accommodate for cookies without values.
Thanks!
- Dominant language
- Python
- Stars
- 54.7k
- Forks
- 10.8k
- Avg merge
- 18m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from psf/requests
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
`iter_lines(decode_unicode=True, delimiter=<str>)` raises `TypeError` when `Response.encoding` is `None`May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
get_encoding_from_headers treats any content type containing 'text' as text/* (ISO-8859-1)Possibly taken @suyashgitt claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Invalid `params` type (e.g. int) raises misleading "TypeError: Cannot mix str and non-str arguments"Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
plot_graph crashes when a mesh node has no m2m edgePossibly taken @tygvi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mllam/neural-lam#883 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement possible-duplicate
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
AOSSIE-Org/PictoPy#1715 · 2 comments ·
Maintainers usually reply within 6 days
-
SQLite connector omits generated columns from the catalog, and drops relationships sourced on themOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NVIDIA/auto-ontology#511 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ethereum/execution-specs#3996 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
cpp-best-practices/project_validator#267 ·
Maintainers usually reply within 1 day