Commit 2b323d0
authored
fix: fix error handling for gRPC and SSE streaming (#879)
Reproduced in `test_client_server_integration.py`.
### gRPC
`validate_async_generator` decorator was applied on top of the method
above A2A error handling. Compat handler was already refactored in a way
which made it possible to apply it on a nested function. It was done
there and v1 handler was refactored in the same way.
### SSE streaming
Iterator wrapped into `validate_async_generator` is assigned to
`EventSourceResponse` and is returned from the method, so when it throws
`rest_stream_error_handler` has no effect on it.
https://github.com/a2aproject/a2a-python/blob/4630efd0ca4bf6934a7d9215ef2a2986b6e6e73a/src/a2a/server/apps/rest/rest_adapter.py#L155-L163
Instead of throwing on the first iteration, throw on the method
invocation itself to avoid more sophisticated error handling (i.e.
reading one item to trigger error) by removing separate handling for
async generator.
Client-level handling is also updated to properly handle non-200 status
code for streaming and non-streaming response in case of JSON-RPC error.1 parent 7437b88 commit 2b323d0
File tree
10 files changed
+317
-283
lines changed- src/a2a
- client/transports
- compat/v0_3
- server/request_handlers
- utils
- tests
- client/transports
- integration
10 files changed
+317
-283
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | 173 | | |
178 | 174 | | |
179 | 175 | | |
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | 236 | | |
241 | 237 | | |
242 | 238 | | |
243 | 239 | | |
244 | 240 | | |
245 | 241 | | |
246 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | 263 | | |
268 | 264 | | |
269 | 265 | | |
270 | 266 | | |
271 | 267 | | |
272 | 268 | | |
273 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
146 | | - | |
| 145 | + | |
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
| |||
0 commit comments