Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connexion error on posting wrong content type to suggest method #698

Closed
juhoinkinen opened this issue Apr 27, 2023 · 1 comment · Fixed by #702
Closed

Connexion error on posting wrong content type to suggest method #698

juhoinkinen opened this issue Apr 27, 2023 · 1 comment · Fixed by #702
Labels
Milestone

Comments

@juhoinkinen
Copy link
Member

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:

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).

This or similar bug has been reported multiple times to connexion, lately in spec-first/connexion#1593.

And it seems that this is fixed by connexion v3, at least the related functionality is modified: spec-first/connexion#1638

Just reporting this now. Let's check this after upgrading to connexion3, which should also get rid of many warnings (#689).

@juhoinkinen juhoinkinen added this to the 1.0 milestone Apr 27, 2023
@juhoinkinen juhoinkinen modified the milestones: 1.0, Short term Aug 15, 2023
@RobbeSneyders
Copy link

Connexion 3 will be released tomorrow.

@juhoinkinen juhoinkinen linked a pull request Feb 26, 2024 that will close this issue
@juhoinkinen juhoinkinen modified the milestones: Short term, 1.1 Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants