Skip to content

Commit 1d62c80

Browse files
committed
test: update serialization tests for MAX_CONTENT_LENGTH
1 parent 9853845 commit 1d62c80

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

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):

0 commit comments

Comments
 (0)