From 66b486bf341b6f8a8ff7127a1b81b42187988abb Mon Sep 17 00:00:00 2001 From: Yurii Karabas <1998uriyyo@gmail.com> Date: Tue, 5 Aug 2025 11:30:24 +0200 Subject: [PATCH] Fix header tests --- fastapi/dependencies/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 58cb9f36c..1f2b7ee30 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -755,7 +755,7 @@ def request_params_to_args( params_to_process: Dict[str, Any] = {} fields_to_extract = [ - cached_field + (field, cached_field) for field in fields if lenient_issubclass(field.type_, BaseModel) for cached_field in get_cached_model_fields(field.type_) @@ -763,13 +763,15 @@ def request_params_to_args( processed_keys = set() - for field in fields_to_extract: + for parent_field, field in fields_to_extract: alias = None if isinstance(received_params, Headers): # Handle fields extracted from a Pydantic Model for a header, each field # doesn't have a FieldInfo of type Header with the default convert_underscores=True convert_underscores = getattr( - field.field_info, "convert_underscores", default_convert_underscores + parent_field.field_info, + "convert_underscores", + default_convert_underscores, ) if convert_underscores: alias = (