Browse Source

fix(dependencies): only set default dependency_cache if it is None

This solves a bug where an empty dictionary would be reassigned.
pull/11323/head
Gustav Bylund 1 year ago
parent
commit
b31a1cd01b
  1. 4
      fastapi/dependencies/utils.py

4
fastapi/dependencies/utils.py

@ -587,7 +587,8 @@ async def solve_dependencies(
response = Response()
del response.headers["content-length"]
response.status_code = None # type: ignore
dependency_cache = dependency_cache or {}
if dependency_cache is None:
dependency_cache = {}
sub_dependant: Dependant
for sub_dependant in dependant.dependencies:
sub_dependant.call = cast(Callable[..., Any], sub_dependant.call)
@ -624,7 +625,6 @@ async def solve_dependencies(
embed_body_fields=embed_body_fields,
)
background_tasks = solved_result.background_tasks
dependency_cache.update(solved_result.dependency_cache)
if solved_result.errors:
errors.extend(solved_result.errors)
continue

Loading…
Cancel
Save