ahopkins / sanic-jwt

Authentication, JWT, and permission scoping for Sanic
http://sanic-jwt.readthedocs.io
MIT License
242 stars 52 forks source link

Unexpected keyword with latest Sanic (21.3.2) #216

Closed its-a-feature closed 3 years ago

its-a-feature commented 3 years ago

I just updated to the latest Sanic (21.3.2) from (20.6) and the latest sanic-jwt (1.6), but now I'm getting some weird error about an unexpected keyword argument:

[2021-04-08 10:52:58 -0700] [61878] [ERROR] Exception occurred while handling uri: 'http://192.168.53.128/api/v1.4/callbacks/30/all_tasking'
Traceback (most recent call last):
  File "./venv/lib/python3.8/site-packages/sanic/app.py", line 724, in handle_request
    response = await response
  File "./venv/lib/python3.8/site-packages/sanic_jwt/decorators.py", line 241, in decorated_function
    return await response
  File "./venv/lib/python3.8/site-packages/sanic_jwt/decorators.py", line 204, in decorated_function
    response = f(request, *args, **kwargs)
TypeError: callbacks_get_all_tasking() got an unexpected keyword argument 'page'

The function is defined:

@mythic.route(
    mythic.config["API_BASE"] + "/callbacks/<id:int>/all_tasking", methods=["GET"]
)
@inject_user()
@scoped(
    ["auth:user", "auth:apitoken_user"], False
)  # user or user-level api token are ok
async def callbacks_get_all_tasking(request, user, id):
    pass

It worked before with Sanic 20.6. Any thoughts?

its-a-feature commented 3 years ago

figured it out. Despite the error bubbling up into sanic_jwt's decorator, it's actually an issue in sanic's parsing of paths and restricted keywords. i.e. i changed

@mythic.route(
    mythic.config["API_BASE"] + "/callbacks/<id:int>/all_tasking", methods=["GET"]
)

to

@mythic.route(
    mythic.config["API_BASE"] + "/callbacks/<cid:int>/all_tasking", methods=["GET"]
)

(id -> cid) and it worked just fine.