Skip to content

Commit 9968f9c

Browse files
fix(deps): DeprecationWarning on HTTP_413_REQUEST_ENTITY_TOO_LARGE (#693)
# Description In [This commit that landed in v0.48.0](Kludex/starlette@40a8147) starlette changed constants to conform to [RFC9110](https://www.rfc-editor.org/rfc/rfc9110#name-413-content-too-large). It's the only [one affected](Kludex/starlette@40a8147#diff-966c562bff3b11736a75544f42526c942c185b9fe9eb4b7f5a0dabbeca874fa7R180) that I could find in this codebase. - [x] Follow the [`CONTRIBUTING` Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests and linter pass (Run `bash scripts/format.sh` from the repository root to format) - [x] Appropriate docs were updated (if necessary) # Tests ```zsh uv sync --all-groups ``` Before and after: confirmed that this is fixed. ```zsh uv run python -W error::DeprecationWarning -c "from a2a.server.apps.jsonrpc.fastapi_app import *" ``` Confirmed that tests worked with ```zsh uv run pytest ``` # Other uv.lock currently has ```toml [[package]] name = "starlette" version = "0.50.0" ``` So I don't think the dependency pinning is a breaking change. --------- Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
1 parent cdd4a91 commit 9968f9c

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/a2a/server/apps/jsonrpc/jsonrpc_app.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@
6464
from starlette.exceptions import HTTPException
6565
from starlette.requests import Request
6666
from starlette.responses import JSONResponse, Response
67-
from starlette.status import HTTP_413_REQUEST_ENTITY_TOO_LARGE
67+
68+
try:
69+
# Starlette v0.48.0
70+
from starlette.status import HTTP_413_CONTENT_TOO_LARGE
71+
except ImportError:
72+
from starlette.status import ( # type: ignore[no-redef]
73+
HTTP_413_REQUEST_ENTITY_TOO_LARGE as HTTP_413_CONTENT_TOO_LARGE,
74+
)
6875

6976
_package_starlette_installed = True
7077
else:
@@ -76,7 +83,14 @@
7683
from starlette.exceptions import HTTPException
7784
from starlette.requests import Request
7885
from starlette.responses import JSONResponse, Response
79-
from starlette.status import HTTP_413_REQUEST_ENTITY_TOO_LARGE
86+
87+
try:
88+
# Starlette v0.48.0
89+
from starlette.status import HTTP_413_CONTENT_TOO_LARGE
90+
except ImportError:
91+
from starlette.status import (
92+
HTTP_413_REQUEST_ENTITY_TOO_LARGE as HTTP_413_CONTENT_TOO_LARGE,
93+
)
8094

8195
_package_starlette_installed = True
8296
except ImportError:
@@ -90,7 +104,7 @@
90104
Request = Any
91105
JSONResponse = Any
92106
Response = Any
93-
HTTP_413_REQUEST_ENTITY_TOO_LARGE = Any
107+
HTTP_413_CONTENT_TOO_LARGE = Any
94108

95109

96110
class StarletteUserProxy(A2AUser):
@@ -381,7 +395,7 @@ async def _handle_requests(self, request: Request) -> Response: # noqa: PLR0911
381395
None, A2AError(root=JSONParseError(message=str(e)))
382396
)
383397
except HTTPException as e:
384-
if e.status_code == HTTP_413_REQUEST_ENTITY_TOO_LARGE:
398+
if e.status_code == HTTP_413_CONTENT_TOO_LARGE:
385399
return self._generate_error_response(
386400
request_id,
387401
A2AError(

0 commit comments

Comments
 (0)