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

Duplicate exception handler definition on: route=__ALL_ROUTES__ and exception=<class 'sanic_jwt.exceptions.SanicJWTException'> #252

Open
deffulsFHSS opened this issue Jan 20, 2024 · 0 comments

Comments

@deffulsFHSS
Copy link

from sanic import Sanic, Blueprint
from sanic_jwt import Initialize

app = Sanic("TestCase")

bp = Blueprint('bp', url_prefix='/api')

app.blueprint(bp)

bp1 = Blueprint('bp1', url_prefix='/test')

app.blueprint(bp1)

Initialize(
    instance=bp,
    app=app,
    authenticate=lambda: True
)

Initialize(
    instance=bp1,
    app=app,
    authenticate=lambda: True
)

print('app', app.router.routes_all.keys())
print('bp', [x.uri for x in bp.routes])

This code gives me following Error. Looks like bug, i don't understand why.

Traceback (most recent call last):
  File "/home/deffuls/Documents/Example/test.py", line 20, in <module>
    Initialize(
  File "/home/deffuls/Documents/Example/env_py/lib/python3.11/site-packages/sanic_jwt/initialization.py", line 137, in __init__
    self.__add_endpoints()
  File "/home/deffuls/Documents/Example/env_py/lib/python3.11/site-packages/sanic_jwt/initialization.py", line 179, in __add_endpoints
    self.app.exception(exceptions.SanicJWTException)(
  File "/home/deffuls/Documents/Example/env_py/lib/python3.11/site-packages/sanic/mixins/exceptions.py", line 37, in decorator
    self._apply_exception_handler(future_exception)
  File "/home/deffuls/Documents/Example/env_py/lib/python3.11/site-packages/sanic/app.py", line 517, in _apply_exception_handler
    self.error_handler.add(exception, handler.handler, route_names)
  File "/home/deffuls/Documents/Example/env_py/lib/python3.11/site-packages/sanic/handlers/error.py", line 73, in add
    self._add((exception, None), handler)
  File "/home/deffuls/Documents/Exampleenv_py/lib/python3.11/site-packages/sanic/handlers/error.py", line 53, in _add
    raise ServerError(message)
sanic.exceptions.ServerError: Duplicate exception handler definition on: route=__ALL_ROUTES__ and exception=<class 'sanic_jwt.exceptions.SanicJWTException'>
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