Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/a2a/server/apps/jsonrpc/jsonrpc_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
Response = Any
HTTP_413_REQUEST_ENTITY_TOO_LARGE = Any

MAX_CONTENT_LENGTH = 1_000_000
MAX_CONTENT_LENGTH = 10_000_000


class StarletteUserProxy(A2AUser):
Expand Down
22 changes: 5 additions & 17 deletions tests/server/apps/jsonrpc/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,18 @@ def test_handle_oversized_payload(agent_card_with_api_key: AgentCard):
app_instance = A2AStarletteApplication(agent_card_with_api_key, handler)
client = TestClient(app_instance.build())

large_string = 'a' * 2_000_000 # 2MB string
large_string = 'a' * 11 * 1_000_000 # 11MB string
payload = {
'jsonrpc': '2.0',
'method': 'test',
'id': 1,
'params': {'data': large_string},
}

# Starlette/FastAPI's default max request size is around 1MB.
# This test will likely fail with a 413 Payload Too Large if the default is not increased.
# If the application is expected to handle larger payloads, the server configuration needs to be adjusted.
# For this test, we expect a 413 or a graceful JSON-RPC error if the app handles it.

try:
response = client.post('/', json=payload)
# If the app handles it gracefully and returns a JSON-RPC error
if response.status_code == 200:
data = response.json()
assert data['error']['code'] == InvalidRequestError().code
else:
assert response.status_code == 413
except Exception as e:
# Depending on server setup, it might just drop the connection for very large payloads
assert isinstance(e, ConnectionResetError | RuntimeError)
response = client.post('/', json=payload)
assert response.status_code == 200
data = response.json()
assert data['error']['code'] == InvalidRequestError().code


def test_handle_unicode_characters(agent_card_with_api_key: AgentCard):
Expand Down
46 changes: 44 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading