sanic-org / sanic-routing

Internal handler routing for Sanic beginning with v21.3.

Home Page:https://sanicframework.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routing error after updating to 0.4.3

VMAtm opened this issue · comments

Hi

We have route in code defined as:

@app.get('/relations/<relation_id>/keys')

Code above worked with sanic 21.3.2 and sanic-router 0.4.2, but with 0.4.3 ends up with error:

Experienced exception while trying to serve
Traceback (most recent call last):
  File "/service/venv/lib/python3.7/site-packages/sanic/app.py", line 918, in run
    serve_single(server_settings)
  File "/service/venv/lib/python3.7/site-packages/sanic/server.py", line 725, in serve_single
    serve(**server_settings)
  File "/service/venv/lib/python3.7/site-packages/sanic/server.py", line 554, in serve
    trigger_events(before_start, loop)
  File "/service/venv/lib/python3.7/site-packages/sanic/server.py", line 354, in trigger_events
    loop.run_until_complete(result)
  File "uvloop/loop.pyx", line 1494, in uvloop.loop.Loop.run_until_complete
  File "/service/venv/lib/python3.7/site-packages/sanic/app.py", line 1280, in finalize
    app.router.finalize()
  File "/service/venv/lib/python3.7/site-packages/sanic/router.py", line 179, in finalize
    super().finalize(*args, **kwargs)
  File "/service/venv/lib/python3.7/site-packages/sanic_routing/router.py", line 185, in finalize
    self._render(do_compile)
  File "/service/venv/lib/python3.7/site-packages/sanic_routing/router.py", line 262, in _render
    "exec",
  File "<string>", line 108
    elif parts[0] == "relations":

Not sure how to resolve this, does somebody have any ideas?

Hi @VMAtm
The actual thrown Python exception is missing from your report. You have the traceback, but what was the Exception? (eg, KeyError, AttributeError, SyntaxError, etc).

I've attempted reproducing this locally but it seems to work as expected. It appears there are more routes in your application that are affecting the route Tree generation. Eg, there must be a route starting with "/relations". I think we'll need to see all of your routes before we can reproduce this exact error.

BTW, this might be incidentally fixed when #17 is merged, I'll let you know to re-test when that is released.

Hi, @ashleysommer, sorry, copied wrong route, updated the code.

Yeah, it's SyntaxError, with probably indentation error or something similar. Let's wait for the #17 and I'll retest then, thank

Do you still see this with the latest version?

Do you still see this with the latest version?

Hi, thank you for the update, will check and return to you as soon as I can

Hi, sorry for such long delay, I can confirm that next version made it to resolve the issue.