Comments (11)
Released: https://pypi.org/project/sanic-routing/0.7.2/
from sanic-routing.
I see the problem. You are indeed correct this is a 🐛
I do not think it will be a difficult fix, but I am also not entirely sure of a good workaround yet. I will try to get an 0.7.2 out this weekend.
Thank you for providing the simple, easy to reproduce test case. This makes it very simple for me to narrow down the issue, and provides us with a pattern for regression testing.
from sanic-routing.
Here's the diff of the fix. If you have a chance to make the PR. If not, I can get to it later tonight.
diff --git a/sanic_routing/router.py b/sanic_routing/router.py
index 8e964d6..210927d 100644
--- a/sanic_routing/router.py
+++ b/sanic_routing/router.py
@@ -424,9 +424,10 @@ class BaseRouter(ABC):
)
route_idx: t.Union[str, int] = 0
+ holder = []
if len(group.routes) > 1:
route_idx = "route_idx"
- Node._inject_method_check(src, 1, group)
+ Node._inject_method_check(holder, 2, group)
src.extend(
[
@@ -438,6 +439,7 @@ class BaseRouter(ABC):
1,
),
Line("if match:", 1),
+ *holder,
Line("basket['__params__'] = match.groupdict()", 2),
Line(
(
from sanic-routing.
Thanks for jumping so quickly on this! This is really great community support! 🙌🏻
Thank you for providing the simple, easy to reproduce test case.
haha 😆 I'm often on the other side at Rasa so I know the pain of a maintainer 😄
from sanic-routing.
haha laughing I'm often on the other side at Rasa so I know the pain of a maintainer smile
Nice to finally "meet" you
from sanic-routing.
Thank you so much! This was really outstanding community support! 🙌🏻 Keep up the great work! 🚀
from sanic-routing.
It seems this was introduced in 0.7.1. Can't reproduce with 0.7.0
from sanic-routing.
As way of explanation of what is happening... this is a portion of the generated router with my own annotations:
# This section only appears RIGHT BEFORE a grouped set of routes.
# In this case, since the same route has a POST and PUT, it helps direct to the correct one
if method in frozenset({'PUT'}):
route_idx = 0
elif method in frozenset({'POST'}):
route_idx = 1
else:
raise NoMethod
# Matching for "/conversation/<conversation_id:path>/tracker/events"
match = router.matchers[0].match(path)
if match:
basket['__params__'] = match.groupdict()
return router.regex_routes[('conversation', '<__dynamic__:path>', 'tracker', 'events')][route_idx], basket
# Matching for "/conversation/<conversation_id:path>/story"
match = router.matchers[1].match(path)
if match:
basket['__params__'] = match.groupdict()
return router.regex_routes[('conversation', '<__dynamic__:path>', 'story')][0], basket
raise NotFound
So, the solution is probably to move the method checking inside the match conditional.
from sanic-routing.
You're my hero! I'll try it out!
from sanic-routing.
Sweet - it works. I'll create a PR - just need to write a test
from sanic-routing.
It helps that it was a simple fix 😆
from sanic-routing.
Related Issues (20)
- `RouteExists` thrown when registering a directory and a missing file to the same route. HOT 1
- path_to_parts parsing bug HOT 6
- Pattern registration auto-compile HOT 1
- Context managed code generation
- Having two or more <path> routes does not work with different methods HOT 6
- Regex params not type cast
- Invalid declaration: <entity_id>:meta HOT 4
- Incorrect handling of `pattern` argument for `register_pattern` HOT 2
- Unique route names
- [Feature] Fallback route when none match HOT 2
- Colon in uri generate response 404 HOT 2
- parts_to_path, raises exception for part with multiple parameters without type hint HOT 1
- Websocket conflicts with http GET
- Unquoted URLs should be case-insensitive
- Parameter types are broken when using <something:path>
- "unquote=True" breaks int path parameters HOT 1
- Parameterized Route returns 404 instead of 405 HOT 2
- Expandable routes have more priority than static routes when adding a trailing slash to the path HOT 2
- Requirements based on equality
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanic-routing.