docs(response): document set_cookie() name/value ASCII restriction (#1445)#2646
Merged
vytas7 merged 1 commit intoMay 21, 2026
Conversation
…alconry#1445) set_cookie() rejects non-ASCII bytes in name (raising KeyError) and in value (raising ValueError) via the existing _is_ascii_encodable checks in falcon/response.py:497-500. The Args entries for name and value just read 'Cookie name' and 'Cookie value', so users hit the runtime error without warning. Issue falconry#1445 reports the same surprise: a Chinese cookie value raises ValueError with no docstring guidance. Spell out the restriction in the parameter docs, point at the RFC 6265 clause, and broaden the Raises entries to mention non-ASCII as a trigger. No behaviour change. Includes 1445.misc.rst towncrier fragment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2646 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 64 64
Lines 7976 7976
Branches 1102 1102
=========================================
Hits 7976 7976 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
vytas7
approved these changes
May 21, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents that
Response.set_cookie()'snameandvaluearguments must be US-ASCII. The runtime check has always raisedKeyError(forname) andValueError(forvalue) on non-ASCII inputs, but the docstring'sArgs:andRaises:sections didn't say so — so users like the original reporter hit the error without warning.Closes #1445.
Change Type
Details
falcon/response.py:374-385—nameandvalueentries now explain the US-ASCII requirement, link to RFC 6265 §4.1.1, and point at common encodings (urllib.parse.quote,base64) for non-ASCII payloads.falcon/response.py:479-482—Raises:entries call out non-ASCII characters as a concrete trigger for the existing exceptions.docs/_newsfragments/1445.misc.rst— towncrier fragment under "Misc".No behaviour change; the runtime behaviour was already in place via
_is_ascii_encodable(name)/_is_ascii_encodable(value)(seefalcon/response.py:497-500).