resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · fastapi/fastapi
🐛 Fix Query\Header\Cookie parameter model alias When we declare Query\Header\Cookie parameter as model and specify `alias` for the field, there are currently 2 issues: 1. Value is extracted by alias, but it's put into `values` with the key `field.name` instead of `key.alias`. Then, when we attempt to validate the model passing `values`, it fails to find the value for that field (because it searches by alias) and we have validation error. 2. If we pass the value by name, we will correctly get validation error, but the `input` field will not contain the extra parameter (passed by name). That's because the `field.name` were mistakenly added to `processed_keys`. We should only add the parameter alias, not both. This PR fixes these two issues
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
--- a/fastapi/dependencies/utils.py
+++ b/fastapi/dependencies/utils.py
@@ -787,9 +787,8 @@ def request_params_to_args(
)
value = _get_multidict_value(field, received_params, alias=alias)
if value is not None:
- params_to_process[field.name] = value
+ params_to_process[field.alias] = value
processed_keys.add(alias or field.alias)
- processed_keys.add(field.name)
for key in received_params.keys():
if key not in processed_keys:...... [100%]
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.
_PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]]
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
6 passed, 1 warning in 0.51s