← eval6_submission

fastapi_14306

failed CONTEXT NO_PATCH UNSUBMITTED agent_error · 46 tool calls · 96 s · fastapi/fastapi

Task input

🚸  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 calls (46)

#ToolArgumentsResult
1run_command
{
 "command": "grep -rn \"ResponseValidationError\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/exceptions.py:175:class ResponseValidationError(ValidationException):\nfastapi/routing.py:51: ResponseValidationError,\nfast
full
{"status": "ok", "stdout": "fastapi/exceptions.py:175:class ResponseValidationError(ValidationException):\nfastapi/routing.py:51:    ResponseValidationError,\nfastapi/routing.py:248:            raise ResponseValidationError(\n", "stderr": "", "exit_code": 0}
2read_file
{
 "filepath": "fastapi/exceptions.py",
 "start_line": "170",
 "end_line": "200"
}
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
full
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
3read_file
{
 "end_line": "200",
 "filepath": "fastapi/exceptions.py",
 "start_line": "150"
}
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
full
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
4read_file
{
 "filepath": "fastapi/exceptions.py"
}
{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "from typing import Any, Dict, Optional, Sequence, Type, Union\n\nfrom annotated_doc import Doc
full
{"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
5run_command
{
 "command": "grep -rn \"RequestValidationError\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/exception_handlers.py:2:from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError\nfastapi/exce
full
{"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/exceptions.py:165:class RequestValidationError(ValidationException):\nfastapi/exceptions.py:171:class WebSocketRequestValidationError(ValidationException):\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", "stderr": "", "exit_code": 0}
6read_file
{
 "filepath": "fastapi/exceptions.py",
 "start_line": "150"
}
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
full
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
7run_command
{
 "command": "cat fastapi/exceptions.py"
}
{"status": "ok", "stdout": "from typing import Any, Dict, Optional, Sequence, Type, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, crea
full
{"status": "ok", "stdout": "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=status_code, detail=detail, headers=headers
8run_command
{
 "command": "cat fastapi/exceptions.py | tail -n 20"
}
{"status": "ok", "stdout": "class RequestValidationError(ValidationException):\n def __init__(self, errors: Sequence[Any], *, body: Any = None) -> None:\n super
full
{"status": "ok", "stdout": "class 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", "stderr": "", "exit_code": 0}
9run_command
{
 "command": "grep -rn \"RequestValidationError\" fastapi/routing.py | head -20"
}
{"status": "ok", "stdout": "50: RequestValidationError,\n52: WebSocketRequestValidationError,\n347: validation_error = RequestValidationError(\n423: validation_
full
{"status": "ok", "stdout": "50:    RequestValidationError,\n52:    WebSocketRequestValidationError,\n347:            validation_error = RequestValidationError(\n423:            validation_error = RequestValidationError(\n453:            raise WebSocketRequestValidationError(\n", "stderr": "", "exit_code": 0}
10read_file
{
 "filepath": "fastapi/routing.py",
 "start_line": "330",
 "end_line": "360"
}
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
full
{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}
11run_command
{
 "command": "cat fastapi/routing.py | sed -n '330,360p'"
}
{"status": "ok", "stdout": " if body_bytes:\n json_body: Any = Undefined\n content_type_value = request.headers.get(\"content-type\")\n if not content_type_valu
full
{"status": "ok", "stdout": "                    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", "stderr": "", "exit_code": 0}
12run_command
{
 "command": "cat fastapi/routing.py | sed -n '410,430p'"
}
{"status": "ok", "stdout": " include=response_model_include,\n exclude=response_model_exclude,\n by_alias=response_model_by_alias,\n exclude_unset=response_mode
full
{"status": "ok", "stdout": "                    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                response.headers.raw.extend(solved_result.response.headers.raw)\n        if errors:\n            validation_error = RequestValidationError(\n                _normalize_errors(errors), body=body\n            )\n            raise validation_error\n\n        # Return response\n        assert response\n        return response\n", "stderr": "", "exit_code": 0}
13run_command
{
 "command": "cat fastapi/routing.py | sed -n '440,460p'"
}
{"status": "ok", "stdout": " async def app(websocket: WebSocket) -> None:\n async_exit_stack = websocket.scope.get(\"fastapi_inner_astack\")\n assert isinstance
full
{"status": "ok", "stdout": "    async def app(websocket: WebSocket) -> None:\n        async_exit_stack = websocket.scope.get(\"fastapi_inner_astack\")\n        assert isinstance(async_exit_stack, AsyncExitStack), (\n            \"fastapi_inner_astack not found in request scope\"\n        )\n        solved_result = await solve_dependencies(\n            request=websocket,\n            dependant=dependant,\n            dependency_overrides_provider=dependency_overrides_provider,\n            async_exit_stack=async_exit_stack,\n            embed_body_fields=embed_body_fields,\n        )\n        if solved_result.errors:\n            raise WebSocketRequestValidationError(\n                _normalize_errors(solved_result.errors)\n            )\n        assert dependant.call is not None, \"dependant.call must be a function\"\n        await dependant.call(**solved_result.values)\n\n    return app\n\n", "stderr": "", "exit_code": 0}
14run_command
{
 "command": "grep -rn \"ResponseValidationError\" fastapi/routing.py | head -20"
}
{"status": "ok", "stdout": "51: ResponseValidationError,\n248: raise ResponseValidationError(\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "51:    ResponseValidationError,\n248:            raise ResponseValidationError(\n", "stderr": "", "exit_code": 0}
15run_command
{
 "command": "cat fastapi/routing.py | sed -n '240,260p'"
}
{"status": "ok", "stdout": " value, errors_ = await run_in_threadpool(\n field.validate, response_content, {}, loc=(\"response\",)\n )\n if isinstance(errors_,
full
{"status": "ok", "stdout": "            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", "stderr": "", "exit_code": 0}
16run_command
{
 "command": "grep -rn \"ValidationException\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/exceptions.py:157:class ValidationException(Exception):\nfastapi/exceptions.py:165:class RequestValidationError(ValidationEx
full
{"status": "ok", "stdout": "fastapi/exceptions.py:157:class ValidationException(Exception):\nfastapi/exceptions.py:165:class RequestValidationError(ValidationException):\nfastapi/exceptions.py:171:class WebSocketRequestValidationError(ValidationException):\nfastapi/exceptions.py:175:class ResponseValidationError(ValidationException):\n", "stderr": "", "exit_code": 0}
17run_command
{
 "command": "cat fastapi/exceptions.py | sed -n '157,184p'"
}
{"status": "ok", "stdout": "class ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(se
full
{"status": "ok", "stdout": "class 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", "stderr": "", "exit_code": 0}
18run_command
{
 "command": "grep -rn \"APIRoute\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/__init__.py:23:from .routing import APIRouter as APIRouter\nfastapi/applications.py:721: Optional[routing.APIRouter],\nfasta
full
{"status": "ok", "stdout": "fastapi/__init__.py:23:from .routing import APIRouter as APIRouter\nfastapi/applications.py:721:            Optional[routing.APIRouter],\nfastapi/applications.py:777:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:922:            routing.APIRouter,\nfastapi/applications.py:925:                The `app.webhooks` attribute is an `APIRouter` with the *path\nfastapi/applications.py:932:        ] = webhooks or routing.APIRouter()\nfastapi/applications.py:968:        self.router: routing.APIRouter = routing.APIRouter(\nfastapi/applications.py:1169:        generate_unique_id_function: Callable[[routing.APIRoute], str] = Default(\nfastapi/applications.py:1225:        generate_unique_id_function: Callable[[routing.APIRoute], str] = Default(\nfastapi/applications.py:1342:        router: Annotated[routing.APIRouter, Doc(\"The `APIRouter` to include.\")],\nfastapi/applications.py:1499:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:1515:        Include an `APIRouter` in the same app.\nfastapi/applications.py:1862:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:2235:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:2613:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:2991:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:3364:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:3737:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:4110:            Callable[[routing.APIRoute], str],\nfastapi/applications.py:4488:            Callable[[routing.APIRoute], str],\n", "stderr": "", "exit_code": 0}
19run_command
{
 "command": "grep -rn \"class APIRoute\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/routing.py:504:class APIRoute(routing.Route):\nfastapi/routing.py:673:class APIRouter(routing.Router):\n", "stderr": "", "ex
full
{"status": "ok", "stdout": "fastapi/routing.py:504:class APIRoute(routing.Route):\nfastapi/routing.py:673:class APIRouter(routing.Router):\n", "stderr": "", "exit_code": 0}
20run_command
{
 "command": "cat fastapi/routing.py | sed -n '500,600p'"
}
{"status": "ok", "stdout": " child_scope[\"route\"] = self\n return match, child_scope\n\n\nclass APIRoute(routing.Route):\n def __init__(\n self,\n path: str,\
full
{"status": "ok", "stdout": "            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                response_model = None\n            else:
21run_command
{
 "command": "cat fastapi/routing.py | sed -n '600,700p'"
}
{"status": "ok", "stdout": " self.secure_cloned_response_field: Optional[ModelField] = (\n create_cloned_field(self.response_field)\n )\n else:\n self.response_
full
{"status": "ok", "stdout": "            self.secure_cloned_response_field: Optional[ModelField] = (\n                create_cloned_field(self.response_field)\n            )\n        else:\n            self.response_field = None  # type: ignore\n            self.secure_cloned_response_field = None\n        self.dependencies = list(dependencies or [])\n        self.description = description or inspect.cleandoc(self.endpoint.__doc__ or \"\")\n        # if a \"form feed\" character (page break) is found in the description text,\n        # truncate description text to the content preceding the first \"form feed\"\n        self.description = self.description.split(\"\\f\")[0].strip()\n        response_fields = {}\n        for additional_status_code, response in self.responses.items():\n            assert isinstance(response, dict), \"An additional response must be a dict\"\n            model = response.get(\"model\")\n            if model:\n                assert is_body_allowed_for_status_code(additional_status_code), (\n                    f\"Status code {additional_status_code} must not have a response body\"\n                )\n                response_name = f\"Response_{additional_status_code}_{self.unique_id}\"\n                response_field = create_model_field(\n                    name=response_name, type_=model, mode=\"serialization\"\n                )\n                response_fields[additional_status_code] = response_field\n        if response_fields:\n            self.response_fields: Dict[Union[int, str], ModelField] = response_fields\n        else:\n            self.response_fields = {}\n\n        assert callable(endpoint), \"An endpoint must be a callable\"\n        self.dependant = get_dependant(\n            path=self.path_format, call=self.endpoint, scope=\"function\"\n        )\n        for depends in self.dependencies[::-1]:\n            self.dependant.dependencies.insert(\n                0,\n                get_parameterless_sub_dependant(depends
22run_command
{
 "command": "grep -rn \"get_request_handler\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/routing.py:279: # Only called by get_request_handler. Has been split into its own function to\nfastapi/routing.py:289:def ge
full
{"status": "ok", "stdout": "fastapi/routing.py:279:    # Only called by get_request_handler. Has been split into its own function to\nfastapi/routing.py:289:def get_request_handler(\nfastapi/routing.py:650:        return get_request_handler(\n", "stderr": "", "exit_code": 0}
23run_command
{
 "command": "cat fastapi/routing.py | sed -n '289,330p'"
}
{"status": "ok", "stdout": "def get_request_handler(\n dependant: Dependant,\n body_field: Optional[ModelField] = None,\n status_code: Optional[int] = None,\n r
full
{"status": "ok", "stdout": "def get_request_handler(\n    dependant: Dependant,\n    body_field: Optional[ModelField] = None,\n    status_code: Optional[int] = None,\n    response_class: Union[Type[Response], DefaultPlaceholder] = Default(JSONResponse),\n    response_field: Optional[ModelField] = 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    dependency_overrides_provider: Optional[Any] = None,\n    embed_body_fields: bool = False,\n) -> Callable[[Request], Coroutine[Any, Any, Response]]:\n    assert dependant.call is not None, \"dependant.call must be a function\"\n    is_coroutine = dependant.is_coroutine_callable\n    is_body_form = body_field and isinstance(\n        body_field.field_info, (params.Form, temp_pydantic_v1_params.Form)\n    )\n    if isinstance(response_class, DefaultPlaceholder):\n        actual_response_class: Type[Response] = response_class.value\n    else:\n        actual_response_class = response_class\n\n    async def app(request: Request) -> Response:\n        response: Union[Response, None] = None\n        file_stack = request.scope.get(\"fastapi_middleware_astack\")\n        assert isinstance(file_stack, AsyncExitStack), (\n            \"fastapi_middleware_astack not found in request scope\"\n        )\n\n        # Read body and auto-close files\n        try:\n            body: Any = None\n            if body_field:\n                if is_body_form:\n                    body = await request.form()\n                    file_stack.push_async_callback(body.close)\n                else:\n                    body_bytes = await request.body()\n                    if body_bytes:\n", "stderr": "", "exit_code": 0}
24run_command
{
 "command": "cat fastapi/routing.py | sed -n '330,450p'"
}
{"status": "ok", "stdout": " if body_bytes:\n json_body: Any = Undefined\n content_type_value = request.headers.get(\"content-type\")\n if not content_type_valu
full
{"status": "ok", "stdout": "                    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        async_exit_stack = request.sc
25run_command
{
 "command": "cat fastapi/routing.py | sed -n '230,260p'"
}
{"status": "ok", "stdout": " # pydantic v1\n response_content = _prepare_response_content(\n response_content,\n exclude_unset=exclude_unset,\n exclude_defaults
full
{"status": "ok", "stdout": "            # 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", "stderr": "", "exit_code": 0}
26run_command
{
 "command": "cat fastapi/routing.py | sed -n '200,230p'"
}
{"status": "ok", "stdout": ") -> Lifespan[Any]:\n @asynccontextmanager\n async def merged_lifespan(\n app: AppType,\n ) -> AsyncIterator[Optional[Mapping[str, A
full
{"status": "ok", "stdout": ") -> Lifespan[Any]:\n    @asynccontextmanager\n    async def merged_lifespan(\n        app: AppType,\n    ) -> AsyncIterator[Optional[Mapping[str, Any]]]:\n        async with original_context(app) as maybe_original_state:\n            async with nested_context(app) as maybe_nested_state:\n                if maybe_nested_state is None and maybe_original_state is None:\n                    yield None  # old ASGI compatibility\n                else:\n                    yield {**(maybe_nested_state or {}), **(maybe_original_state or {})}\n\n    return merged_lifespan  # type: ignore[return-value]\n\n\nasync def serialize_response(\n    *,\n    field: Optional[ModelField] = None,\n    response_content: Any,\n    include: Optional[IncEx] = None,\n    exclude: Optional[IncEx] = None,\n    by_alias: bool = True,\n    exclude_unset: bool = False,\n    exclude_defaults: bool = False,\n    exclude_none: bool = False,\n    is_coroutine: bool = True,\n) -> Any:\n    if field:\n        errors = []\n        if not hasattr(field, \"serialize\"):\n            # pydantic v1\n", "stderr": "", "exit_code": 0}
27run_command
{
 "command": "grep -rn \"solve_dependencies\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:587:async def solve_dependencies(\nfastapi/dependencies/utils.py:638: solved_result = await solve_depe
full
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:587:async def solve_dependencies(\nfastapi/dependencies/utils.py:638:        solved_result = await solve_dependencies(\nfastapi/routing.py:45:    solve_dependencies,\nfastapi/routing.py:375:        solved_result = await solve_dependencies(\nfastapi/routing.py:445:        solved_result = await solve_dependencies(\n", "stderr": "", "exit_code": 0}
28run_command
{
 "command": "cat fastapi/dependencies/utils.py | sed -n '587,650p'"
}
{"status": "ok", "stdout": "async def solve_dependencies(\n *,\n request: Union[Request, WebSocket],\n dependant: Dependant,\n body: Optional[Union[Dict[str, An
full
{"status": "ok", "stdout": "async def solve_dependencies(\n    *,\n    request: Union[Request, WebSocket],\n    dependant: Dependant,\n    body: Optional[Union[Dict[str, Any], FormData]] = None,\n    background_tasks: Optional[StarletteBackgroundTasks] = None,\n    response: Optional[Response] = None,\n    dependency_overrides_provider: Optional[Any] = None,\n    dependency_cache: Optional[Dict[DependencyCacheKey, Any]] = None,\n    # TODO: remove this parameter later, no longer used, not removing it yet as some\n    # people might be monkey patching this function (although that's not supported)\n    async_exit_stack: AsyncExitStack,\n    embed_body_fields: bool,\n) -> SolvedDependency:\n    request_astack = request.scope.get(\"fastapi_inner_astack\")\n    assert isinstance(request_astack, AsyncExitStack), (\n        \"fastapi_inner_astack not found in request scope\"\n    )\n    function_astack = request.scope.get(\"fastapi_function_astack\")\n    assert isinstance(function_astack, AsyncExitStack), (\n        \"fastapi_function_astack not found in request scope\"\n    )\n    values: Dict[str, Any] = {}\n    errors: List[Any] = []\n    if response is None:\n        response = Response()\n        del response.headers[\"content-length\"]\n        response.status_code = None  # type: ignore\n    if dependency_cache is None:\n        dependency_cache = {}\n    for sub_dependant in dependant.dependencies:\n        sub_dependant.call = cast(Callable[..., Any], sub_dependant.call)\n        call = sub_dependant.call\n        use_sub_dependant = sub_dependant\n        if (\n            dependency_overrides_provider\n            and dependency_overrides_provider.dependency_overrides\n        ):\n            original_call = sub_dependant.call\n            call = getattr(\n                dependency_overrides_provider, \"dependency_overrides\", {}\n            ).get(original_call, original_call)\n            use_path: str = sub_dependant.path  # type: ignore\n            use_su
29run_command
{
 "command": "cat fastapi/routing.py | sed -n '504,600p'"
}
{"status": "ok", "stdout": "class APIRoute(routing.Route):\n def __init__(\n self,\n path: str,\n endpoint: Callable[..., Any],\n *,\n response_model: Any = Def
full
{"status": "ok", "stdout": "class 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                response_model = None\n            else:\n                response_model = return_annotation\n        self.response_model 
30run_command
{
 "command": "cat fastapi/routing.py | sed -n '600,650p'"
}
{"status": "ok", "stdout": " self.secure_cloned_response_field: Optional[ModelField] = (\n create_cloned_field(self.response_field)\n )\n else:\n self.response_
full
{"status": "ok", "stdout": "            self.secure_cloned_response_field: Optional[ModelField] = (\n                create_cloned_field(self.response_field)\n            )\n        else:\n            self.response_field = None  # type: ignore\n            self.secure_cloned_response_field = None\n        self.dependencies = list(dependencies or [])\n        self.description = description or inspect.cleandoc(self.endpoint.__doc__ or \"\")\n        # if a \"form feed\" character (page break) is found in the description text,\n        # truncate description text to the content preceding the first \"form feed\"\n        self.description = self.description.split(\"\\f\")[0].strip()\n        response_fields = {}\n        for additional_status_code, response in self.responses.items():\n            assert isinstance(response, dict), \"An additional response must be a dict\"\n            model = response.get(\"model\")\n            if model:\n                assert is_body_allowed_for_status_code(additional_status_code), (\n                    f\"Status code {additional_status_code} must not have a response body\"\n                )\n                response_name = f\"Response_{additional_status_code}_{self.unique_id}\"\n                response_field = create_model_field(\n                    name=response_name, type_=model, mode=\"serialization\"\n                )\n                response_fields[additional_status_code] = response_field\n        if response_fields:\n            self.response_fields: Dict[Union[int, str], ModelField] = response_fields\n        else:\n            self.response_fields = {}\n\n        assert callable(endpoint), \"An endpoint must be a callable\"\n        self.dependant = get_dependant(\n            path=self.path_format, call=self.endpoint, scope=\"function\"\n        )\n        for depends in self.dependencies[::-1]:\n            self.dependant.dependencies.insert(\n                0,\n                get_parameterless_sub_dependant(depends
31run_command
{
 "command": "cat fastapi/routing.py | sed -n '650,670p'"
}
{"status": "ok", "stdout": " return get_request_handler(\n dependant=self.dependant,\n body_field=self.body_field,\n status_code=self.status_code,\n response_cl
full
{"status": "ok", "stdout": "        return get_request_handler(\n            dependant=self.dependant,\n            body_field=self.body_field,\n            status_code=self.status_code,\n            response_class=self.response_class,\n            response_field=self.secure_cloned_response_field,\n            response_model_include=self.response_model_include,\n            response_model_exclude=self.response_model_exclude,\n            response_model_by_alias=self.response_model_by_alias,\n            response_model_exclude_unset=self.response_model_exclude_unset,\n            response_model_exclude_defaults=self.response_model_exclude_defaults,\n            response_model_exclude_none=self.response_model_exclude_none,\n            dependency_overrides_provider=self.dependency_overrides_provider,\n            embed_body_fields=self._embed_body_fields,\n        )\n\n    def matches(self, scope: Scope) -> Tuple[Match, Scope]:\n        match, child_scope = super().matches(scope)\n        if match != Match.NONE:\n            child_scope[\"route\"] = self\n        return match, child_scope\n", "stderr": "", "exit_code": 0}
32run_command
{
 "command": "grep -rn \"import inspect\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/models.py:1:import inspect\nfastapi/dependencies/utils.py:2:import inspect\nfastapi/routing.py:4:import inspect
full
{"status": "ok", "stdout": "fastapi/dependencies/models.py:1:import inspect\nfastapi/dependencies/utils.py:2:import inspect\nfastapi/routing.py:4:import inspect\nfastapi/openapi/utils.py:2:import inspect\n", "stderr": "", "exit_code": 0}
33run_command
{
 "command": "grep -rn \"import os\" fastapi | head -20"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
34run_command
{
 "command": "grep -rn \"import sys\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/models.py:2:import sys\nfastapi/dependencies/utils.py:3:import sys\nfastapi/_compat/may_v1.py:1:import sys\nfas
full
{"status": "ok", "stdout": "fastapi/dependencies/models.py:2:import sys\nfastapi/dependencies/utils.py:3:import sys\nfastapi/_compat/may_v1.py:1:import sys\nfastapi/_compat/shared.py:1:import sys\nfastapi/_compat/main.py:1:import sys\n", "stderr": "", "exit_code": 0}
35run_command
{
 "command": "cat fastapi/exceptions.py | sed -n '157,184p'"
}
{"status": "ok", "stdout": "class ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(se
full
{"status": "ok", "stdout": "class 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", "stderr": "", "exit_code": 0}
36run_command
{
 "command": "cat fastapi/exceptions.py | sed -n '1,150p'"
}
{"status": "ok", "stdout": "from typing import Any, Dict, Optional, Sequence, Type, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, crea
full
{"status": "ok", "stdout": "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=status_code, detail=detail, headers=headers
37run_command
{
 "command": "cat fastapi/exceptions.py | sed -n '150,157p'"
}
{"status": "ok", "stdout": "class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n (
full
{"status": "ok", "stdout": "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", "stderr": "", "exit_code": 0}
38run_command
{
 "command": "cat fastapi/exceptions.py | sed -n '157,184p'"
}
{"status": "ok", "stdout": "class ValidationException(Exception):\n def __init__(self, errors: Sequence[Any]) -> None:\n self._errors = errors\n\n def errors(se
full
{"status": "ok", "stdout": "class 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", "stderr": "", "exit_code": 0}
39run_command
{
 "command": "cat fastapi/routing.py | sed -n '240,260p'"
}
{"status": "ok", "stdout": " value, errors_ = await run_in_threadpool(\n field.validate, response_content, {}, loc=(\"response\",)\n )\n if isinstance(errors_,
full
{"status": "ok", "stdout": "            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", "stderr": "", "exit_code": 0}
40run_command
{
 "command": "cat fastapi/routing.py | sed -n '340,360p'"
}
{"status": "ok", "stdout": " if subtype == \"json\" or subtype.endswith(\"+json\"):\n json_body = await request.json()\n if json_body != Undefined:\n body = jso
full
{"status": "ok", "stdout": "                                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", "stderr": "", "exit_code": 0}
41run_command
{
 "command": "cat fastapi/routing.py | sed -n '420,440p'"
}
{"status": "ok", "stdout": " response.body = b\"\"\n response.headers.raw.extend(solved_result.response.headers.raw)\n if errors:\n validation_error = RequestVa
full
{"status": "ok", "stdout": "                    response.body = b\"\"\n                response.headers.raw.extend(solved_result.response.headers.raw)\n        if errors:\n            validation_error = RequestValidationError(\n                _normalize_errors(errors), body=body\n            )\n            raise validation_error\n\n        # Return response\n        assert response\n        return response\n\n    return app\n\n\ndef get_websocket_app(\n    dependant: Dependant,\n    dependency_overrides_provider: Optional[Any] = None,\n    embed_body_fields: bool = False,\n) -> Callable[[WebSocket], Coroutine[Any, Any, Any]]:\n    async def app(websocket: WebSocket) -> None:\n", "stderr": "", "exit_code": 0}
42run_command
{
 "command": "cat fastapi/routing.py | sed -n '450,460p'"
}
{"status": "ok", "stdout": " embed_body_fields=embed_body_fields,\n )\n if solved_result.errors:\n raise WebSocketRequestValidationError(\n _normalize_errors(so
full
{"status": "ok", "stdout": "            embed_body_fields=embed_body_fields,\n        )\n        if solved_result.errors:\n            raise WebSocketRequestValidationError(\n                _normalize_errors(solved_result.errors)\n            )\n        assert dependant.call is not None, \"dependant.call must be a function\"\n        await dependant.call(**solved_result.values)\n\n    return app\n\n", "stderr": "", "exit_code": 0}
43run_command
{
 "command": "cat fastapi/routing.py | sed -n '504,520p'"
}
{"status": "ok", "stdout": "class APIRoute(routing.Route):\n def __init__(\n self,\n path: str,\n endpoint: Callable[..., Any],\n *,\n response_model: Any = Def
full
{"status": "ok", "stdout": "class 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", "stderr": "", "exit_code": 0}
44run_command
{
 "command": "cat fastapi/routing.py | sed -n '640,660p'"
}
{"status": "ok", "stdout": " self._flat_dependant.body_params\n )\n self.body_field = get_body_field(\n flat_dependant=self._flat_dependant,\n name=self.unique_
full
{"status": "ok", "stdout": "            self._flat_dependant.body_params\n        )\n        self.body_field = get_body_field(\n            flat_dependant=self._flat_dependant,\n            name=self.unique_id,\n            embed_body_fields=self._embed_body_fields,\n        )\n        self.app = request_response(self.get_route_handler())\n\n    def get_route_handler(self) -> Callable[[Request], Coroutine[Any, Any, Response]]:\n        return get_request_handler(\n            dependant=self.dependant,\n            body_field=self.body_field,\n            status_code=self.status_code,\n            response_class=self.response_class,\n            response_field=self.secure_cloned_response_field,\n            response_model_include=self.response_model_include,\n            response_model_exclude=self.response_model_exclude,\n            response_model_by_alias=self.response_model_by_alias,\n            response_model_exclude_unset=self.response_model_exclude_unset,\n            response_model_exclude_defaults=self.response_model_exclude_defaults,\n", "stderr": "", "exit_code": 0}
45run_command
{
 "command": "cat fastapi/routing.py | sed -n '660,675p'"
}
{"status": "ok", "stdout": " response_model_exclude_defaults=self.response_model_exclude_defaults,\n response_model_exclude_none=self.response_model_exclude_non
full
{"status": "ok", "stdout": "            response_model_exclude_defaults=self.response_model_exclude_defaults,\n            response_model_exclude_none=self.response_model_exclude_none,\n            dependency_overrides_provider=self.dependency_overrides_provider,\n            embed_body_fields=self._embed_body_fields,\n        )\n\n    def matches(self, scope: Scope) -> Tuple[Match, Scope]:\n        match, child_scope = super().matches(scope)\n        if match != Match.NONE:\n            child_scope[\"route\"] = self\n        return match, child_scope\n\n\nclass APIRouter(routing.Router):\n    \"\"\"\n    `APIRouter` class, used to group *path operations*, for example to structure\n", "stderr": "", "exit_code": 0}
46run_command
{
 "command": "cat fastapi/routing.py | sed -n '289,310p'"
}
{"status": "ok", "stdout": "def get_request_handler(\n dependant: Dependant,\n body_field: Optional[ModelField] = None,\n status_code: Optional[int] = None,\n r
full
{"status": "ok", "stdout": "def get_request_handler(\n    dependant: Dependant,\n    body_field: Optional[ModelField] = None,\n    status_code: Optional[int] = None,\n    response_class: Union[Type[Response], DefaultPlaceholder] = Default(JSONResponse),\n    response_field: Optional[ModelField] = 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    dependency_overrides_provider: Optional[Any] = None,\n    embed_body_fields: bool = False,\n) -> Callable[[Request], Coroutine[Any, Any, Response]]:\n    assert dependant.call is not None, \"dependant.call must be a function\"\n    is_coroutine = dependant.is_coroutine_callable\n    is_body_form = body_field and isinstance(\n        body_field.field_info, (params.Form, temp_pydantic_v1_params.Form)\n    )\n    if isinstance(response_class, DefaultPlaceholder):\n        actual_response_class: Type[Response] = response_class.value\n", "stderr": "", "exit_code": 0}