From 8a05f569a411cfe56cd87a5fc5b78c26738fd1d6 Mon Sep 17 00:00:00 2001 From: bahtya Date: Mon, 6 Apr 2026 11:04:43 +0800 Subject: [PATCH] Fix get_path_param_names to strip path converters The regex {(.*?)} captures 'param:path' instead of 'param' when path converters are used. This causes implicit path params to be incorrectly treated as query params. Fix: use {([^:}]+)} to stop at the colon separator. Fixes #14883 --- fastapi/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi/utils.py b/fastapi/utils.py index 12eaa2bf08..3aa1f2e3b3 100644 --- a/fastapi/utils.py +++ b/fastapi/utils.py @@ -41,7 +41,7 @@ def is_body_allowed_for_status_code(status_code: int | str | None) -> bool: def get_path_param_names(path: str) -> set[str]: - return set(re.findall("{(.*?)}", path)) + return set(re.findall("{([^:}]+)", path)) _invalid_args_message = (