If an Authorization header cannot be decoded using UTF-8 then a traceback is logged #4027

Closed
opened 2023-05-05 23:42:13 +00:00 by exarkun · 1 comment
2023-05-05T19:39:51-0400 twisted.web.server.Request#critical 
        Traceback (most recent call last):
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/server.py", line 292, in render
            body = resrc.render(self)
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_resource.py", line 215, in render
            d = maybeDeferred(_execute)
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/internet/defer.py", line 206, in maybeDeferred
            result = f(*args, **kwargs)
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_resource.py", line 205, in _execute
            d = maybeDeferred(
        --- <exception caught here> ---
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/internet/defer.py", line 206, in maybeDeferred
            result = f(*args, **kwargs)
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 230, in execute_endpoint
            return endpoint_f(
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 366, in _f
            return _call(instance, f, request, *a, **kw)
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 124, in _call
            result = *klein_f*(*args, **kwargs)
          File "/home/exarkun/Work/python/tahoe-lafs/src/allmydata/storage/http_server.py", line 120, in route
            request.requestHeaders.getRawHeaders("Authorization", [""])[
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/http_headers.py", line 271, in getRawHeaders
            return [for v in values]v.decode("utf8")
          File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/http_headers.py", line 271, in <listcomp>
            return [for v in values]v.decode("utf8")
        builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 17: invalid start byte

The request can presumably not receive any kind of success response but it should probably not trigger logging of a traceback either.

``` 2023-05-05T19:39:51-0400 twisted.web.server.Request#critical Traceback (most recent call last): File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/server.py", line 292, in render body = resrc.render(self) File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_resource.py", line 215, in render d = maybeDeferred(_execute) File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/internet/defer.py", line 206, in maybeDeferred result = f(*args, **kwargs) File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_resource.py", line 205, in _execute d = maybeDeferred( --- <exception caught here> --- File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/internet/defer.py", line 206, in maybeDeferred result = f(*args, **kwargs) File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 230, in execute_endpoint return endpoint_f( File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 366, in _f return _call(instance, f, request, *a, **kw) File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/klein/_app.py", line 124, in _call result = *klein_f*(*args, **kwargs) File "/home/exarkun/Work/python/tahoe-lafs/src/allmydata/storage/http_server.py", line 120, in route request.requestHeaders.getRawHeaders("Authorization", [""])[ File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/http_headers.py", line 271, in getRawHeaders return [for v in values]v.decode("utf8") File "/home/exarkun/VirtualEnvs/tahoe-lafs/lib/python3.9/site-packages/twisted/web/http_headers.py", line 271, in <listcomp> return [for v in values]v.decode("utf8") builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 17: invalid start byte ``` The request can presumably not receive any kind of success response but it should probably not trigger logging of a traceback either.
exarkun added the
unknown
normal
defect
n/a
labels 2023-05-05 23:42:13 +00:00
exarkun added this to the HTTP Storage Protocol milestone 2023-05-05 23:42:13 +00:00
GitHub <noreply@github.com> commented 2023-05-23 18:53:26 +00:00
Owner

In d510103/trunk:

Merge pull request #1301 from tahoe-lafs/4027-invalid-unicode

Invalid unicode in Authorization header should give better response

Fixes ticket:4027
In [d510103/trunk](/tahoe-lafs/trac-2024-07-25/commit/d510103f965cd7529038ee3ca0e5f5cdeccb938a): ``` Merge pull request #1301 from tahoe-lafs/4027-invalid-unicode Invalid unicode in Authorization header should give better response Fixes ticket:4027 ```
tahoe-lafs added the
fixed
label 2023-05-23 18:53:26 +00:00
Sign in to join this conversation.
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: tahoe-lafs/trac-2024-07-25#4027
No description provided.