Skip to content

Fix (Sanic 21.3): TypeError: sentry_router_get() takes 2 positional arguments but 4 were given#1066

Closed
SaidBySolo wants to merge 6 commits into
getsentry:masterfrom
Saebasol:sanic-integrations-fix
Closed

Fix (Sanic 21.3): TypeError: sentry_router_get() takes 2 positional arguments but 4 were given#1066
SaidBySolo wants to merge 6 commits into
getsentry:masterfrom
Saebasol:sanic-integrations-fix

Conversation

@SaidBySolo

@SaidBySolo SaidBySolo commented Mar 28, 2021

Copy link
Copy Markdown

Fixed an issue with processing requests in 21.3.

@SaidBySolo SaidBySolo changed the title Fix Sanic 21.3 TypeError: sentry_router_get() takes 2 positional arguments but 4 were given Fix (Sanic 21.3): TypeError: sentry_router_get() takes 2 positional arguments but 4 were given Mar 28, 2021

@cakemanny cakemanny left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 21.3 and later the first non-self argument is no longer a Request, it's the path, so this looks a bit confusing.
Since request is not being used, is there a reason to not just write it as follows?

def sentry_router_get(self, *args):
    # type: (Router, *Any) -> Any
    rv = old_router_get(self, *args)
    hub = Hub.current
    ...

@SaidBySolo

SaidBySolo commented Apr 30, 2021

Copy link
Copy Markdown
Author

In 21.3 and later the first non-self argument is no longer a Request, it's the path, so this looks a bit confusing.
Since request is not being used, is there a reason to not just write it as follows?

def sentry_router_get(self, *args):
    # type: (Router, *Any) -> Any
    rv = old_router_get(self, *args)
    hub = Hub.current
    ...

it was burdensome to modify the code that worked fine.

I have reduced the changes as much as possible and only changed the changes for 21.3.

@SaidBySolo SaidBySolo mentioned this pull request Jun 8, 2021
@cakemanny

Copy link
Copy Markdown

Hey @untitaker or @ahmedetefy, what's needed for this PR to make it in? Hopefully you are the right people to ask.
We are currently stuck on an ageing version of Sanic and can't upgrade without this

@HazAT

HazAT commented Jul 5, 2021

Copy link
Copy Markdown
Member

We will handle it this week

@ahmedetefy

Copy link
Copy Markdown
Contributor

Hey @cakemanny did you manage to run the tests for sanic > 21.0?
I have tried running tests for version 21.3 and they seem to be broken

@cakemanny

Copy link
Copy Markdown

Hey @ahmedetefy, well, I have now 😅 . Looks like they broke when going from 20.9.x to 20.12.x :(

This is what you were seeing, yes?

_____________________________________________________________________ ERROR at setup of test_errors ______________________________________________________________________
tests/integrations/sanic/test_sanic.py:19: in app
    app = Sanic(__name__)
venv/lib/python3.7/site-packages/sanic/app.py:97: in __init__
    self.__class__.register_app(self)
venv/lib/python3.7/site-packages/sanic/app.py:1444: in register_app
    raise SanicException(f'Sanic app name "{name}" already in use.')
E   sanic.exceptions.SanicException: Sanic app name "tests.integrations.sanic.test_sanic" already in use.
...

Basically it looks like they've added a check to stop people accidentally re-declaring the same app.
I'll try to have a look into this but I'm shortly about to go on holiday for a week and a half. So if anyone else reading this wants to look in the meantime, feel free.

@ahmedetefy

Copy link
Copy Markdown
Contributor

No need, I have already picked this up.. will push a PR soon

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.

4 participants