← oracle_full

fastapi_14791

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) · None tool calls · 0 s · fastapi/fastapi

Task input

🐛 Update `ValidationError` schema to include `input` and `ctx`

## Summary

Related to #10787

The OpenAPI `ValidationError` schema was outdated and didn't reflect the actual error format returned by Pydantic V2.

## Changes
Updated `validation_error_definition` in `fastapi/openapi/utils.py` to include:
- `input`: The actual input value that caused the validation error  
- `ctx`: Optional context dictionary with additional error information

## Testing
All existing tests pass with the updated schema. The test snapshots have been updated to reflect the new schema structure.

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/fastapi/openapi/utils.py
+++ b/fastapi/openapi/utils.py
@@ -49,6 +49,8 @@
         },
         "msg": {"title": "Message", "type": "string"},
         "type": {"title": "Error Type", "type": "string"},
+        "input": {"title": "Input"},
+        "ctx": {"title": "Context", "type": "object"},
     },
     "required": ["loc", "msg", "type"],
 }

Test output

show
==================================== ERRORS ====================================
______________ ERROR collecting tests/test_forms_single_param.py _______________
tests/test_forms_single_param.py:9: in <module>
    @app.post("/form/")
     ^^^^^^^^^^^^^^^^^^
fastapi/routing.py:1063: in decorator
    self.add_api_route(
fastapi/routing.py:1002: in add_api_route
    route = route_class(
fastapi/routing.py:621: in __init__
    self.dependant = get_dependant(
fastapi/dependencies/utils.py:276: in get_dependant
    param_details = analyze_param(
fastapi/dependencies/utils.py:495: in analyze_param
    ensure_multipart_is_installed()
fastapi/dependencies/utils.py:109: in ensure_multipart_is_installed
    raise RuntimeError(multipart_not_installed_error) from None
E   RuntimeError: Form data requires "python-multipart" to be installed. 
E   You can install "python-multipart" with: 
E   
E   pip install python-multipart
=============================== 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
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 warning, 1 error in 0.93s