Skip to content

Commit

Permalink
fix validation of path params on static paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Feb 16, 2023
1 parent fa01674 commit d6fa5f4
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 68 deletions.
119 changes: 63 additions & 56 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "starlite"
version = "1.51.2"
version = "1.51.3"
description = "Performant, light and flexible ASGI API Framework"
authors = ["Na'aman Hirschfeld <[email protected]>"]
maintainers = [
Expand Down
15 changes: 14 additions & 1 deletion starlite/asgi/routing_trie/validate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from itertools import chain
from typing import TYPE_CHECKING

from starlite.exceptions import ImproperlyConfiguredException
Expand All @@ -21,7 +22,19 @@ def validate_node(node: "RouteTrieNode") -> None:
if node.is_asgi and bool(set(node.asgi_handlers).difference({"asgi"})):
raise ImproperlyConfiguredException("ASGI handlers must have a unique path not shared by other route handlers.")

if node.is_mount and node.children and any(child.path_parameters for child in node.children.values()):
if (
node.is_mount
and node.children
and any(
v
for v in chain.from_iterable(
list(child.path_parameters.values())
if isinstance(child.path_parameters, dict)
else child.path_parameters
for child in node.children.values()
)
)
):
raise ImproperlyConfiguredException("Path parameters are not allowed under a static or mount route.")

for child in node.children.values():
Expand Down
Loading

0 comments on commit d6fa5f4

Please sign in to comment.