Commit 8f31f87
fix: return UnsupportedOperationError when subscribing to terminal tasks (#784)
Per A2A spec, attempting to subscribe to a task in a terminal state
(completed, failed, canceled, rejected) must return
UnsupportedOperationError.
The issue had two parts:
1. DefaultRequestHandler checked terminal state AFTER queue operations
began, causing errors to be delivered via SSE stream instead of
immediately.
2. For streaming endpoints (subscribeToTask), immediate errors must be
wrapped in SSE format so the client's SSE parser can process them and
deliver to the error handler callback. Previously they were sent as
plain JSON/HTTP responses which the SSE parser couldn't handle.
Changes:
- Move terminal state validation BEFORE queue operations in
DefaultRequestHandler
- Wrap all immediate errors in SSE format for JSON-RPC routing layer
- Wrap all immediate errors in SSE format for REST transport
- Add integration test to verify fix across all three transports
Applied to HTTP+JSON, JSON-RPC, and gRPC transports.
Fixes #767
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent d3f88cb commit 8f31f87
5 files changed
Lines changed: 95 additions & 45 deletions
File tree
- reference/jsonrpc/src/main/java/io/a2a/server/apps/quarkus
- server-common/src/main/java/io/a2a/server/requesthandlers
- tests/server-common/src/test/java/io/a2a/server/apps/common
- transport/jsonrpc/src
- main/java/io/a2a/transport/jsonrpc/handler
- test/java/io/a2a/transport/jsonrpc/handler
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
449 | 456 | | |
450 | | - | |
451 | 457 | | |
452 | 458 | | |
453 | 459 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
835 | 846 | | |
836 | 847 | | |
837 | 848 | | |
838 | 849 | | |
839 | 850 | | |
840 | 851 | | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | 852 | | |
846 | 853 | | |
847 | 854 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1130 | 1130 | | |
1131 | 1131 | | |
1132 | 1132 | | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1133 | 1193 | | |
1134 | 1194 | | |
1135 | 1195 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
391 | 394 | | |
| 395 | + | |
392 | 396 | | |
393 | 397 | | |
394 | 398 | | |
| |||
Lines changed: 6 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | 988 | | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
1019 | 994 | | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
| 995 | + | |
1023 | 996 | | |
1024 | 997 | | |
1025 | 998 | | |
| |||
0 commit comments