Skip to content

docs(response): document set_cookie() name/value ASCII restriction (#1445)#2646

Merged
vytas7 merged 1 commit into
falconry:masterfrom
mvanhorn:docs/1445-cookie-name-value-ascii-restriction
May 21, 2026
Merged

docs(response): document set_cookie() name/value ASCII restriction (#1445)#2646
vytas7 merged 1 commit into
falconry:masterfrom
mvanhorn:docs/1445-cookie-name-value-ascii-restriction

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Documents that Response.set_cookie()'s name and value arguments must be US-ASCII. The runtime check has always raised KeyError (for name) and ValueError (for value) on non-ASCII inputs, but the docstring's Args: and Raises: sections didn't say so — so users like the original reporter hit the error without warning.

Closes #1445.

Change Type

  • Documentation

Details

  • falcon/response.py:374-385name and value entries 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-482Raises: 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) (see falcon/response.py:497-500).

…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
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b1b683a) to head (b506c84).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@CaselIT CaselIT requested a review from vytas7 May 19, 2026 21:44
Copy link
Copy Markdown
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mvanhorn

@vytas7 vytas7 merged commit eddfeb4 into falconry:master May 21, 2026
33 checks passed
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge @CaselIT @vytas7 - glad the cookie ASCII restriction docs landed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document set_cookie() name/value restrictions (strings are limited to US-ASCII)

3 participants