Closed juhoinkinen closed 3 months ago
A connexion error occurs if application/json content-type is used in requests to /v1/projects/<project>/suggest method.
/v1/projects/<project>/suggest
For example this curl request produces a 500 response:
curl -X POST -H "Content-Type: application/json" -d '{"documents": [{"text": "content"}]}' http://localhost:5000/v1/projects/tfidf-fi/suggest
And the server logs show:
Exception on /v1/projects/tfidf-fi/suggest [POST] Traceback (most recent call last): File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request() File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 68, in wrapper response = function(request) File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper response = function(request) File "/home/local/jmminkin/.cache/pypoetry/virtualenvs/annif-ul-EXdhi-py3.8/lib/python3.8/site-packages/connexion/decorators/validation.py", line 173, in wrapper data.update(dict.fromkeys(request.files, '')) # validator expects string.. AttributeError: 'bytes' object has no attribute 'update' INFO:werkzeug:127.0.0.1 - - [27/Apr/2023 11:29:30] "POST /v1/projects/tfidf-fi/suggest HTTP/1.1" 500 -
This is otherwise harmless but the error message is wrong and can be confusing (the above curl command is correct for the suggest-batch method).
suggest-batch
This or similar bug has been reported multiple times to connexion, lately in https://github.com/spec-first/connexion/issues/1593.
And it seems that this is fixed by connexion v3, at least the related functionality is modified: https://github.com/spec-first/connexion/issues/1638
Just reporting this now. Let's check this after upgrading to connexion3, which should also get rid of many warnings (https://github.com/NatLibFi/Annif/issues/689).
Connexion 3 will be released tomorrow.
A connexion error occurs if application/json content-type is used in requests to
/v1/projects/<project>/suggest
method.For example this curl request produces a 500 response:
And the server logs show:
This is otherwise harmless but the error message is wrong and can be confusing (the above curl command is correct for the
suggest-batch
method).This or similar bug has been reported multiple times to connexion, lately in https://github.com/spec-first/connexion/issues/1593.
And it seems that this is fixed by connexion v3, at least the related functionality is modified: https://github.com/spec-first/connexion/issues/1638
Just reporting this now. Let's check this after upgrading to connexion3, which should also get rid of many warnings (https://github.com/NatLibFi/Annif/issues/689).