@@ -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
151139def test_handle_unicode_characters (agent_card_with_api_key : AgentCard ):
0 commit comments