#147 confusing error spew from wsgiref after obtaining an OpenID Connect token
Closed: Invalid 4 years ago Opened 4 years ago by zbyszek.

$ waiverdb-cli -r 123 -r 456 -p "fedora-26" -c "It's dead\!"
Please visit https://id.fedoraproject.org/openidc/Authorization?scope=openid+https%3A%2F%2Fwaiverdb.fedoraproject.org%2Foidc%2Fcreate-waiver&response_type=code&client_id=waiverdb-authorizer&redirect_uri=http%3A%2F%2Flocalhost%3A12345%2F&response_mode=query to grant authorization
127.0.0.1 - - [12/Mar/2018 22:26:02] "GET /?code=37ddb838-7237-4d44-9610-72a6a69ceba3_we3jRg1bv5mKAWzGlHqOky3aljMtnOVz HTTP/1.1" 200 0
Traceback (most recent call last):
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 266, in write
    "write() argument must be a bytes instance"
AssertionError: write() argument must be a bytes instance
127.0.0.1 - - [12/Mar/2018 22:26:02] "GET /?code=37ddb838-7237-4d44-9610-72a6a69ceba3_we3jRg1bv5mKAWzGlHqOky3aljMtnOVz HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59722)
Traceback (most recent call last):
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 266, in write
    "write() argument must be a bytes instance"
AssertionError: write() argument must be a bytes instance

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib64/python3.6/socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib64/python3.6/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "/usr/lib64/python3.6/wsgiref/simple_server.py", line 133, in handle
    handler.run(self.server.get_app())
  File "/usr/lib64/python3.6/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib64/python3.6/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
Error: Failed to create waiver for result with id 123:
Result id not found in Resultsdb

Looks like some basic type confusion.


Hmm. A bit strange.

I think all the wsgiref spew is actually from the OpenID Connect support library, which does some fun stuff with calling back to localhost for getting OpenID tokens. Did I test this after we switched to Python 3? ... No I probably did not. I forgot. And it's not covered by the test suite...

Anyway, after all the scary spew, there is an actual error which is expected in this case:

Error: Failed to create waiver for result with id 123:
Result id not found in Resultsdb

I think that one is legit. There is no result 123 in ResultsDB. We probably need to improve that example...

Updated the bug title to be just about the scary-looking wsgiref errors from the OpenID Connect token step.

Importantly, obtaining the token does still succeed in spite of all the error messages, and the CLI does then successfully proceed.

I can reproduce this, and it is clearly Python 3 related. Sadly, there seems to be zero chance that we can actually cover this in Waiverdb's test suite, because it requires a working browser and an OpenID Connect provider which will accept a nonsense username+password for testing.

Okay. This needs fixing in python-openidc-client. I've filed a PR here:
https://github.com/puiterwijk/python-openidc-client/pull/5

Closing this as "invalid" in the sense that there is nothing more we need to do in Waiverdb for the wsgiref errors. I will follow up with the fix in openidc-client.

Thanks for reporting this.

Metadata Update from @dcallagh:
- Issue assigned to dcallagh
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata