failed LOOP NO_PATCH LOOP empty_patch(timeout) · 32 tool calls · 0 s · fastapi/fastapi
🚸 Improve tracebacks by adding endpoint metadata
Today, when validation errors occur, error messages don't indicate what endpoint caused the problem, which can make debugging difficult.
This PR adds endpoint context metadata to validation error messages to show the filepath (clickable in IDEs!) and line number, function name and HTTP method and route where applicable. The endpoint context is extracted once per endpoint and then cached to avoid any additional performance overhead on subsequent requests. Just to double check, I also ran a rough benchmark (100k requests):
```
Baseline (without changes): 0.0006s
Uncached: 1.3281s (13.28µs per request)
**Cached**: 0.0060s (0.06µs per request)
```
Endpoint context only appears in the exception's string representation (server logs). It is **not** exposed to clients in HTTP responses. Clients still receive the standard 422 response with validation error details.
## Examples
### ResponseValidationError
**Before:**
```
fastapi.exceptions.ResponseValidationError: 1 validation error:
{'type': 'missing', 'loc': ('response', 'id'), 'msg': 'Field required', 'input': {'name': 'Widget'}}
```
**After:**
```
fastapi.exceptions.ResponseValidationError: 1 validation error:
{'type': 'missing', 'loc': ('response', 'id'), 'msg': 'Field required', 'input': {'name': 'Widget'}}
File "/Users/savannah/work/fastapi/capture_real_examples.py", line 43, in create_item
POST /items/
```
### RequestValidationError
**Before:**
```
fastapi.exceptions.RequestValidationError: 1 validation error:
{'type': 'int_parsing', 'loc': ('path', 'user_id'), 'msg': 'Input should be a valid integer, unable to parse string as an integer', 'input': 'invalid'}
```
**After:**
```
fastapi.exceptions.RequestValidationError: 1 validation error:
{'type': 'int_parsing', 'loc': ('path', 'user_id'), 'msg': 'Input should be a valid integer, unable to parse string as an integer', 'input': 'invalid'}
File "/Users/savannah/work/fastapi/capture_real_examples.py", line 38, in get_user
GET /users/{user_id}
```
### WebSocketRequestValidationError
**Before:**
```
fastapi.exceptions.WebSocketRequestValidationError: 1 validation error:
{'type': 'int_parsing', 'loc': ('path', 'item_id'), 'msg': 'Input should be a valid integer, unable to parse string as an integer', 'input': 'invalid'}
```
**After:**
```
fastapi.exceptions.WebSocketRequestValidationError: 1 validation error:
{'type': 'int_parsing', 'loc': ('path', 'item_id'), 'msg': 'Input should be a valid integer, unable to parse string as an integer', 'input': 'invalid'}
File "/Users/savannah/work/fastapi/capture_real_examples.py", line 48, in websocket_endpoint
WS /ws/{item_id}
```| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"RequestValidationError\" fastapi/exceptions.py"
} | {"status": "ok", "stdout": "165:class RequestValidationError(ValidationException):\n171:class WebSocketRequestValidationError(ValidationException):\n", "exit_cofull{"status": "ok", "stdout": "165:class RequestValidationError(ValidationException):\n171:class WebSocketRequestValidationError(ValidationException):\n", "exit_code": 0} |
| 2 | read_file | {
"filepath": "fastapi/exceptions.py",
"start_line": 150,
"end_line": 200
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on full{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (narrower) scope.\n \"\"\"\n\n\nclass ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n\nclass RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n\nclass WebSocketRequestValidationError(ValidationException):\n pass\n\n\nclass ResponseValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation errors:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n return message\n", "start_line": 150, "end_line": 184, "total_lines": 184, "is_truncated": false} |
| 3 | run_command | {
"command": "grep -rn \"RequestValidationError\" fastapi/ | grep -v \"exceptions.py\""
} | {"status": "ok", "stdout": "fastapi/exception_handlers.py:2:from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError\nfastapi/excefull{"status": "ok", "stdout": "fastapi/exception_handlers.py:2:from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError\nfastapi/exception_handlers.py:21: request: Request, exc: RequestValidationError\nfastapi/exception_handlers.py:30: websocket: WebSocket, exc: WebSocketRequestValidationError\nfastapi/applications.py:24:from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError\nfastapi/applications.py:988: RequestValidationError, request_validation_exception_handler\nfastapi/applications.py:991: WebSocketRequestValidationError,\nfastapi/routing.py:50: RequestValidationError,\nfastapi/routing.py:52: WebSocketRequestValidationError,\nfastapi/routing.py:347: validation_error = RequestValidationError(\nfastapi/routing.py:423: validation_error = RequestValidationError(\nfastapi/routing.py:453: raise WebSocketRequestValidationError(\n", "exit_code": 0} |
| 4 | read_file | {
"end_line": 460,
"filepath": "fastapi/routing.py",
"start_line": 330
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": " if body_bytes:\n json_body: Any = Undefined\n content_type_value = request.headers.get(\"contentfull{"status": "ok", "filepath": "fastapi/routing.py", "content": " if body_bytes:\n json_body: Any = Undefined\n content_type_value = request.headers.get(\"content-type\")\n if not content_type_value:\n json_body = await request.json()\n else:\n message = email.message.Message()\n message[\"content-type\"] = content_type_value\n if message.get_content_maintype() == \"application\":\n subtype = message.get_content_subtype()\n if subtype == \"json\" or subtype.endswith(\"+json\"):\n json_body = await request.json()\n if json_body != Undefined:\n body = json_body\n else:\n body = body_bytes\n except json.JSONDecodeError as e:\n validation_error = RequestValidationError(\n [\n {\n \"type\": \"json_invalid\",\n \"loc\": (\"body\", e.pos),\n \"msg\": \"JSON decode error\",\n \"input\": {},\n \"ctx\": {\"error\": e.msg},\n }\n ],\n body=e.doc,\n )\n raise validation_error from e\n except HTTPException:\n # If a middleware raises an HTTPException, it should be raised again\n raise\n except Exception as e:\n http_error = HTTPException(\n status_code=400, detail=\"There was an error parsing the body\"\n )\n raise http_error from e\n\n # Solve dependencies and run path operation function, auto-closing dependencies\n errors: List[Any] = []\n |
| 5 | read_file | {
"end_line": 420,
"filepath": "fastapi/routing.py",
"start_line": 390
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": " if isinstance(raw_response, Response):\n if raw_response.background is None:\n raw_response.backfull{"status": "ok", "filepath": "fastapi/routing.py", "content": " if isinstance(raw_response, Response):\n if raw_response.background is None:\n raw_response.background = solved_result.background_tasks\n response = raw_response\n else:\n response_args: Dict[str, Any] = {\n \"background\": solved_result.background_tasks\n }\n # If status_code was set, use it, otherwise use the default from the\n # response class, in the case of redirect it's 307\n current_status_code = (\n status_code if status_code else solved_result.response.status_code\n )\n if current_status_code is not None:\n response_args[\"status_code\"] = current_status_code\n if solved_result.response.status_code:\n response_args[\"status_code\"] = solved_result.response.status_code\n content = await serialize_response(\n field=response_field,\n response_content=raw_response,\n include=response_model_include,\n exclude=response_model_exclude,\n by_alias=response_model_by_alias,\n exclude_unset=response_model_exclude_unset,\n exclude_defaults=response_model_exclude_defaults,\n exclude_none=response_model_exclude_none,\n is_coroutine=is_coroutine,\n )\n response = actual_response_class(content, **response_args)\n if not is_body_allowed_for_status_code(response.status_code):\n response.body = b\"\"\n", "start_line": 390, "end_line": 420, "total_lines": 4517, "is_truncated": false} |
| 6 | run_command | {
"command": "grep -rn \"ResponseValidationError\" fastapi/routing.py"
} | {"status": "ok", "stdout": "51: ResponseValidationError,\n248: raise ResponseValidationError(\n", "exit_code": 0}full{"status": "ok", "stdout": "51: ResponseValidationError,\n248: raise ResponseValidationError(\n", "exit_code": 0} |
| 7 | read_file | {
"end_line": 260,
"filepath": "fastapi/routing.py",
"start_line": 230
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": " # pydantic v1\n response_content = _prepare_response_content(\n response_content,\n exclude_unsefull{"status": "ok", "filepath": "fastapi/routing.py", "content": " # pydantic v1\n response_content = _prepare_response_content(\n response_content,\n exclude_unset=exclude_unset,\n exclude_defaults=exclude_defaults,\n exclude_none=exclude_none,\n )\n if is_coroutine:\n value, errors_ = field.validate(response_content, {}, loc=(\"response\",))\n else:\n value, errors_ = await run_in_threadpool(\n field.validate, response_content, {}, loc=(\"response\",)\n )\n if isinstance(errors_, list):\n errors.extend(errors_)\n elif errors_:\n errors.append(errors_)\n if errors:\n raise ResponseValidationError(\n errors=_normalize_errors(errors), body=response_content\n )\n\n if hasattr(field, \"serialize\"):\n return field.serialize(\n value,\n include=include,\n exclude=exclude,\n by_alias=by_alias,\n exclude_unset=exclude_unset,\n exclude_defaults=exclude_defaults,\n exclude_none=exclude_none,\n", "start_line": 230, "end_line": 260, "total_lines": 4517, "is_truncated": false} |
| 8 | read_file | {
"end_line": 100,
"filepath": "fastapi/exceptions.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "from typing import Any, Dict, Optional, Sequence, Type, Union\n\nfrom annotated_doc import Docfull{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "from typing import Any, Dict, Optional, Sequence, Type, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\nfrom typing_extensions import Annotated\n\n\nclass HTTPException(StarletteHTTPException):\n \"\"\"\n An HTTP exception you can raise in your own code to show errors to the client.\n\n This is for client errors, invalid authentication, invalid data, etc. Not for server\n errors in your code.\n\n Read more about it in the\n [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).\n\n ## Example\n\n ```python\n from fastapi import FastAPI, HTTPException\n\n app = FastAPI()\n\n items = {\"foo\": \"The Foo Wrestlers\"}\n\n\n @app.get(\"/items/{item_id}\")\n async def read_item(item_id: str):\n if item_id not in items:\n raise HTTPException(status_code=404, detail=\"Item not found\")\n return {\"item\": items[item_id]}\n ```\n \"\"\"\n\n def __init__(\n self,\n status_code: Annotated[\n int,\n Doc(\n \"\"\"\n HTTP status code to send to the client.\n \"\"\"\n ),\n ],\n detail: Annotated[\n Any,\n Doc(\n \"\"\"\n Any data to be sent to the client in the `detail` key of the JSON\n response.\n \"\"\"\n ),\n ] = None,\n headers: Annotated[\n Optional[Dict[str, str]],\n Doc(\n \"\"\"\n Any headers to send to the client in the response.\n \"\"\"\n ),\n ] = None,\n ) -> None:\n super().__init__(status_code=statu |
| 9 | read_file | {
"end_line": 184,
"filepath": "fastapi/exceptions.py",
"start_line": 140
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "RequestErrorModel: Type[BaseModel] = create_model(\"Request\")\nWebSocketErrorModel: Type[Basefull{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "RequestErrorModel: Type[BaseModel] = create_model(\"Request\")\nWebSocketErrorModel: Type[BaseModel] = create_model(\"WebSocket\")\n\n\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (narrower) scope.\n \"\"\"\n\n\nclass ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n\nclass RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n\nclass WebSocketRequestValidationError(ValidationException):\n pass\n\n\nclass ResponseValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation errors:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n return message\n", "start_line": 140, "end_line": 184, "total_lines": 184, "is_truncated": false} |
| 10 | read_file | {
"end_line": 150,
"filepath": "fastapi/exceptions.py",
"start_line": 140
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "RequestErrorModel: Type[BaseModel] = create_model(\"Request\")\nWebSocketErrorModel: Type[Basefull{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "RequestErrorModel: Type[BaseModel] = create_model(\"Request\")\nWebSocketErrorModel: Type[BaseModel] = create_model(\"WebSocket\")\n\n\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass DependencyScopeError(FastAPIError):\n", "start_line": 140, "end_line": 150, "total_lines": 184, "is_truncated": false} |
| 11 | read_file | {
"end_line": 184,
"filepath": "fastapi/exceptions.py",
"start_line": 150
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on full{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (narrower) scope.\n \"\"\"\n\n\nclass ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n\nclass RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n\nclass WebSocketRequestValidationError(ValidationException):\n pass\n\n\nclass ResponseValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation errors:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n return message\n", "start_line": 150, "end_line": 184, "total_lines": 184, "is_truncated": false} |
| 12 | read_file | {
"end_line": 100,
"filepath": "fastapi/routing.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": "import dataclasses\nimport email.message\nimport functools\nimport inspect\nimport json\nfrom confull{"status": "ok", "filepath": "fastapi/routing.py", "content": "import dataclasses\nimport email.message\nimport functools\nimport inspect\nimport json\nfrom contextlib import AsyncExitStack, asynccontextmanager\nfrom enum import Enum, IntEnum\nfrom typing import (\n Any,\n AsyncIterator,\n Awaitable,\n Callable,\n Collection,\n Coroutine,\n Dict,\n List,\n Mapping,\n Optional,\n Sequence,\n Set,\n Tuple,\n Type,\n Union,\n)\n\nfrom annotated_doc import Doc\nfrom fastapi import params, temp_pydantic_v1_params\nfrom fastapi._compat import (\n ModelField,\n Undefined,\n _get_model_config,\n _model_dump,\n _normalize_errors,\n lenient_issubclass,\n)\nfrom fastapi.datastructures import Default, DefaultPlaceholder\nfrom fastapi.dependencies.models import Dependant\nfrom fastapi.dependencies.utils import (\n _should_embed_body_fields,\n get_body_field,\n get_dependant,\n get_flat_dependant,\n get_parameterless_sub_dependant,\n get_typed_return_annotation,\n solve_dependencies,\n)\nfrom fastapi.encoders import jsonable_encoder\nfrom fastapi.exceptions import (\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)\nfrom fastapi.types import DecoratedCallable, IncEx\nfrom fastapi.utils import (\n create_cloned_field,\n create_model_field,\n generate_unique_id,\n get_value_or_default,\n is_body_allowed_for_status_code,\n)\nfrom pydantic import BaseModel\nfrom starlette import routing\nfrom starlette._exception_handler import wrap_app_handling_exceptions\nfrom starlette._utils import is_async_callable\nfrom starlette.concurrency import run_in_threadpool\nfrom starlette.exceptions import HTTPException\nfrom starlette.requests import Request\nfrom starlette.responses import JSONResponse, Response\nfrom starlette.routing import (\n BaseRoute,\n Match,\n compile_path,\n get_name,\n)\nfrom starlette.routing im |
| 13 | read_file | {
"end_line": 200,
"filepath": "fastapi/routing.py",
"start_line": 101
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": " async with AsyncExitStack() as request_stack:\n scope[\"fastapi_inner_astack\"] = request_stack\full{"status": "ok", "filepath": "fastapi/routing.py", "content": " async with AsyncExitStack() as request_stack:\n scope[\"fastapi_inner_astack\"] = request_stack\n async with AsyncExitStack() as function_stack:\n scope[\"fastapi_function_astack\"] = function_stack\n response = await f(request)\n await response(scope, receive, send)\n # Continues customization\n response_awaited = True\n if not response_awaited:\n raise FastAPIError(\n \"Response not awaited. There's a high chance that the \"\n \"application code is raising an exception and a dependency with yield \"\n \"has a block with a bare except, or a block with except Exception, \"\n \"and is not raising the exception again. Read more about it in the \"\n \"docs: https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-except\"\n )\n\n # Same as in Starlette\n await wrap_app_handling_exceptions(app, request)(scope, receive, send)\n\n return app\n\n\n# Copy of starlette.routing.websocket_session modified to include the\n# dependencies' AsyncExitStack\ndef websocket_session(\n func: Callable[[WebSocket], Awaitable[None]],\n) -> ASGIApp:\n \"\"\"\n Takes a coroutine `func(session)`, and returns an ASGI application.\n \"\"\"\n # assert asyncio.iscoroutinefunction(func), \"WebSocket endpoints must be async\"\n\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n session = WebSocket(scope, receive=receive, send=send)\n\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n async with AsyncExitStack() as request_stack:\n scope[\"fastapi_inner_astack\"] = request_stack\n async with AsyncExitStack( |
| 14 | run_command | {
"command": "grep -rn \"class APIRoute\" fastapi/routing.py"
} | {"status": "ok", "stdout": "504:class APIRoute(routing.Route):\n673:class APIRouter(routing.Router):\n", "exit_code": 0}full{"status": "ok", "stdout": "504:class APIRoute(routing.Route):\n673:class APIRouter(routing.Router):\n", "exit_code": 0} |
| 15 | read_file | {
"end_line": 600,
"filepath": "fastapi/routing.py",
"start_line": 500
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": " child_scope[\"route\"] = self\n return match, child_scope\n\n\nclass APIRoute(routing.Route):\n full{"status": "ok", "filepath": "fastapi/routing.py", "content": " child_scope[\"route\"] = self\n return match, child_scope\n\n\nclass APIRoute(routing.Route):\n def __init__(\n self,\n path: str,\n endpoint: Callable[..., Any],\n *,\n response_model: Any = Default(None),\n status_code: Optional[int] = None,\n tags: Optional[List[Union[str, Enum]]] = None,\n dependencies: Optional[Sequence[params.Depends]] = None,\n summary: Optional[str] = None,\n description: Optional[str] = None,\n response_description: str = \"Successful Response\",\n responses: Optional[Dict[Union[int, str], Dict[str, Any]]] = None,\n deprecated: Optional[bool] = None,\n name: Optional[str] = None,\n methods: Optional[Union[Set[str], List[str]]] = None,\n operation_id: Optional[str] = None,\n response_model_include: Optional[IncEx] = None,\n response_model_exclude: Optional[IncEx] = None,\n response_model_by_alias: bool = True,\n response_model_exclude_unset: bool = False,\n response_model_exclude_defaults: bool = False,\n response_model_exclude_none: bool = False,\n include_in_schema: bool = True,\n response_class: Union[Type[Response], DefaultPlaceholder] = Default(\n JSONResponse\n ),\n dependency_overrides_provider: Optional[Any] = None,\n callbacks: Optional[List[BaseRoute]] = None,\n openapi_extra: Optional[Dict[str, Any]] = None,\n generate_unique_id_function: Union[\n Callable[[\"APIRoute\"], str], DefaultPlaceholder\n ] = Default(generate_unique_id),\n ) -> None:\n self.path = path\n self.endpoint = endpoint\n if isinstance(response_model, DefaultPlaceholder):\n return_annotation = get_typed_return_annotation(endpoint)\n if lenient_issubclass(return_annotation, Response):\n respo |
| 16 | run_command | {
"command": "grep -rn \"def __str__\" fastapi/exceptions.py"
} | {"status": "ok", "stdout": "180: def __str__(self) -> str:\n", "exit_code": 0}full{"status": "ok", "stdout": "180: def __str__(self) -> str:\n", "exit_code": 0} |
| 17 | read_file | {
"end_line": 184,
"filepath": "fastapi/exceptions.py",
"start_line": 150
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on full{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (narrower) scope.\n \"\"\"\n\n\nclass ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n\nclass RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n\nclass WebSocketRequestValidationError(ValidationException):\n pass\n\n\nclass ResponseValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation errors:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n return message\n", "start_line": 150, "end_line": 184, "total_lines": 184, "is_truncated": false} |
| 18 | run_command | {
"command": "grep -rn \"def __str__\" fastapi/exceptions.py"
} | {"status": "ok", "stdout": "180: def __str__(self) -> str:\n", "exit_code": 0}full{"status": "ok", "stdout": "180: def __str__(self) -> str:\n", "exit_code": 0} |
| 19-32 ×14 | read_file | {
"end_line": 184,
"filepath": "fastapi/exceptions.py",
"start_line": 150
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on full{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (narrower) scope.\n \"\"\"\n\n\nclass ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n\nclass RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n\nclass WebSocketRequestValidationError(ValidationException):\n pass\n\n\nclass ResponseValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super().__init__(errors)\n self.body = body\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation errors:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n return message\n", "start_line": 150, "end_line": 184, "total_lines": 184, "is_truncated": false} |
| 33 | submit_patch | [] | {"status": "ok", "patch_size": 0, "files_changed": 0}full{"status": "ok", "patch_size": 0, "files_changed": 0} |