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

PATCH incorrectly checks content_type in certain situations #684

Open
artagel opened this issue Mar 8, 2018 · 1 comment
Open

PATCH incorrectly checks content_type in certain situations #684

artagel opened this issue Mar 8, 2018 · 1 comment

Comments

@artagel
Copy link

artagel commented Mar 8, 2018

When running a PATCH operation, if the content type header isn't set, then the content_type variable is set to None. When this occurs, you traceback on evaluating startswith on None
Line 1499 of views.py

        content_type = request.headers.get('Content-Type', None)
        content_is_json = content_type.startswith('application/json')

Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.5/dist-packages/flask_restless/views.py", line 157, in decorator
    return func(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/mimerender.py", line 244, in wrapper
    result = target(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 149, in dispatch_request
    return meth(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask_restless/views.py", line 189, in wrapped
    return func(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/flask_restless/views.py", line 1499, in patch
    content_is_json = content_type.startswith('application/json')
AttributeError: 'NoneType' object has no attribute 'startswith'
@artagel
Copy link
Author

artagel commented Mar 8, 2018

Version 0.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant