Skip to content

Commit 5b81385

Browse files
authored
fix: change MAX_CONTENT_LENGTH (for file attachment) in json-rpc to be larger size (10mb) (#518)
# Description The current max content length for file attachment in an A2A request is only 1mb which is too small for most files. Change MAX_CONTENT_LENGTH to be larger size (10mb). (Note currently we only have this limit for json-rpc)
1 parent d585635 commit 5b81385

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
Response = Any
9292
HTTP_413_REQUEST_ENTITY_TOO_LARGE = Any
9393

94-
MAX_CONTENT_LENGTH = 1_000_000
94+
MAX_CONTENT_LENGTH = 10_000_000
9595

9696

9797
class StarletteUserProxy(A2AUser):

tests/server/apps/jsonrpc/test_serialization.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,18 @@ def test_handle_oversized_payload(agent_card_with_api_key: AgentCard):
122122
app_instance = A2AStarletteApplication(agent_card_with_api_key, handler)
123123
client = TestClient(app_instance.build())
124124

125-
large_string = 'a' * 2_000_000 # 2MB string
125+
large_string = 'a' * 11 * 1_000_000 # 11MB string
126126
payload = {
127127
'jsonrpc': '2.0',
128128
'method': 'test',
129129
'id': 1,
130130
'params': {'data': large_string},
131131
}
132132

133-
# Starlette/FastAPI's default max request size is around 1MB.
134-
# This test will likely fail with a 413 Payload Too Large if the default is not increased.
135-
# If the application is expected to handle larger payloads, the server configuration needs to be adjusted.
136-
# For this test, we expect a 413 or a graceful JSON-RPC error if the app handles it.
137-
138-
try:
139-
response = client.post('/', json=payload)
140-
# If the app handles it gracefully and returns a JSON-RPC error
141-
if response.status_code == 200:
142-
data = response.json()
143-
assert data['error']['code'] == InvalidRequestError().code
144-
else:
145-
assert response.status_code == 413
146-
except Exception as e:
147-
# Depending on server setup, it might just drop the connection for very large payloads
148-
assert isinstance(e, ConnectionResetError | RuntimeError)
133+
response = client.post('/', json=payload)
134+
assert response.status_code == 200
135+
data = response.json()
136+
assert data['error']['code'] == InvalidRequestError().code
149137

150138

151139
def test_handle_unicode_characters(agent_card_with_api_key: AgentCard):

uv.lock

Lines changed: 44 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)