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

fix: a unexpected token #566

Closed
wants to merge 0 commits into from
Closed

fix: a unexpected token #566

wants to merge 0 commits into from

Conversation

Dog-Egg
Copy link
Contributor

@Dog-Egg Dog-Egg commented Dec 30, 2024

I found a bug while using the automated testing tool.

curl -X GET -H 'Authorization: Bearer ,,0' http://localhost:5000/myapi

This request caused an exception.

ERROR    app:app.py:875 Exception on /myapi [GET]
Traceback (most recent call last):
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask/app.py", line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask/app.py", line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask_jwt_extended/view_decorators.py", line 167, in decorator
    verify_jwt_in_request(
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask_jwt_extended/view_decorators.py", line 94, in verify_jwt_in_request
    jwt_data, jwt_header, jwt_location = _decode_jwt_from_request(
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask_jwt_extended/view_decorators.py", line 340, in _decode_jwt_from_request
    encoded_token, csrf_token = get_encoded_token_function()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lee/workspace/oneproject-logo/.venv/lib/python3.12/site-packages/flask_jwt_extended/view_decorators.py", line 206, in _decode_jwt_from_headers
    jwt_headers = [s for s in field_values if s.split()[0] == header_type]
                                              ~~~~~~~~~^^^
IndexError: list index out of range

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

Successfully merging this pull request may close these issues.

1 participant