Better handling of invalid WSGI path encoding
- Dominant language
- Python
- Stars
- 9.8k
- Forks
- 1k
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 9
Description
Split from #1685: as reported by @rokclimb15, in some cases the WSGI path may Unicode characters that don't comply with the WSGI spec. According to [PEP 3333](https://peps.python.org/pep-3333/#unicode-issues):
> On Python platforms where the `str` or `StringType` type is in fact Unicode-based (e.g. Jython, IronPython, Python 3, etc.), all “strings” referred to in this specification must contain only code points representable in ISO-8859-1 encoding (`\u0000` through `\u00FF`, inclusive). It is a fatal error for an application to supply strings containing any other Unicode character or code point. Similarly, servers and gateways **must not** supply strings to an application containing any other Unicode characters.
Per this definition, Falcon actually handles this correctly by exploding with an unhandled error, that is what a fatal error is.
However, if it is not too expensive to catch this error, maybe we could render an HTTP 400 response anyway, providing a helpful message explaining what was the actual problem? Or alternatively, bubble up an unhandled error, but provide a more helpful message explaining what exactly is going on (with a reference to the spec).
Contributor guide
Research direction
Start by tracing Falcon's WSGI path handling and the unhandled error produced for non-ISO-8859-1 characters. Read PEP 3333's Unicode issues guidance alongside the existing behavior. Done means deciding whether to return HTTP 400 with a helpful message or preserve the unhandled error while making its cause and specification reference clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100