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

parts_to_path, raises exception for part with multiple parameters without type hint #68

Closed
riokuu opened this issue Nov 10, 2022 · 1 comment

Comments

@riokuu
Copy link

riokuu commented Nov 10, 2022

import sanic_routing.utils as sru
sru.path_to_parts('/asd/<int1>,<int2>')
('asd', '<int1>,<int2>')
sru.parts_to_path(sru.path_to_parts('/asd/<int1>,<int2>'))
Traceback (most recent call last):
  File "/srv/git/sensors-server/venv/lib/python3.9/site-packages/sanic_routing/utils.py", line 75, in parts_to_path
    if match.group(2):
AttributeError: 'NoneType' object has no attribute 'group'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/srv/git/sensors-server/venv/lib/python3.9/site-packages/sanic_routing/utils.py", line 83, in parts_to_path
    if match.group(2):
AttributeError: 'NoneType' object has no attribute 'group'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/srv/git/sensors-server/venv/lib/python3.9/site-packages/sanic_routing/utils.py", line 93, in parts_to_path
    raise InvalidUsage(f"Invalid declaration: {part}")
sanic_routing.exceptions.InvalidUsage: Invalid declaration: <int1>,<int2>
@riokuu riokuu changed the title parts_to_path, raises exception for part with multiple parameters without type hint. parts_to_path, raises exception for part with multiple parameters without type hint Nov 10, 2022
@ahopkins
Copy link
Member

Correct. That is an invalid path. Multiple matches per segment is not supported. You should use a custom regex matcher.

https://sanic.dev/en/guide/basics/routing.html#path-parameters

@ahopkins ahopkins closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2022
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

2 participants