Repository navigation
Commit dc5a5da
authored
feat(rest): serve HTTP+JSON responses as application/a2a+json (a2aproject#1274)
## What
Spec
[11.1](https://a2a-protocol.org/latest/specification/#111-protocol-requirements):
"**Content-Type:** application/a2a+json **SHOULD** be used for requests
and responses". The spec uses it in every worked HTTP+JSON example -
20-plus of them.
Every REST response inherited Starlette's `JSONResponse.media_type`
default of `application/json`. `application/a2a+json` appeared nowhere
in the repo, so the constant is new.
## Worth knowing: nobody implements this
All four SDKs with published ACTS metrics - python, go, java, rust -
fail `REST-CT-001`. It is a SHOULD, so it blocks no one's conformance,
and a reasonable response to this PR is "not yet, let the others move
first". Merging it makes a2a-python the first. Flagging it rather than
burying it, since the other six PRs in this stack all had at least one
SDK already passing to corroborate them.
## Two limits, both deliberate
**Success responses only.** The error path runs through
`rest_error_handler`, which `compat/v0_3/rest_adapter.py` shares. 11.1
is the 1.0 binding's requirement, and v0.3 predates the media type, so
changing that decorator would alter a different protocol version's wire
format. Splitting it would mean making a bare decorator parameterized
and touching every call site in both bindings - not worth it for a
SHOULD the corpus does not test on the error path. The result is that
1.0 errors still answer `application/json`; worth a follow-up, not worth
bundling here.
**Responses only, not requests.** 11.1 says both, but changing what the
client *sends* risks servers that only accept `application/json`, and no
test covers it.
**No `JSONResponse` subclass.** It would have reduced nine sites to an
import swap, but `rest_dispatcher.py` aliases `JSONResponse = Any` when
Starlette is absent, and `class X(Any)` is a `TypeError` on Python 3.10,
which this package supports. Passing `media_type=` explicitly keeps the
no-Starlette path importable and the sites greppable.
## Result
Clears `REST-CT-001` (`should`, rest only). With it, **all three
bindings are at zero failures at every level**:
| binding | passed | must | failed |
| --- | --- | --- | --- |
| jsonrpc | 101/111 | 59/59 | 0 |
| grpc | 88/111 | 47/47 | 0 |
| rest | 92/111 | 49/49 | 0 |
The remainder are skips whose preconditions the fixture does not meet,
not failures.1 parent 83f1cf8 commit dc5a5da
4 files changed
Lines changed: 45 additions & 11 deletions
File tree
- .github/actions/spelling
- src/a2a
- server/routes
- utils
- tests/server/routes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
54 | | - | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| |||
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
175 | | - | |
| 181 | + | |
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
| |||
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
213 | | - | |
| 219 | + | |
214 | 220 | | |
215 | 221 | | |
216 | 222 | | |
| |||
246 | 252 | | |
247 | 253 | | |
248 | 254 | | |
249 | | - | |
| 255 | + | |
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
| |||
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
271 | | - | |
| 277 | + | |
272 | 278 | | |
273 | 279 | | |
274 | 280 | | |
| |||
286 | 292 | | |
287 | 293 | | |
288 | 294 | | |
289 | | - | |
| 295 | + | |
290 | 296 | | |
291 | 297 | | |
292 | 298 | | |
| |||
305 | 311 | | |
306 | 312 | | |
307 | 313 | | |
308 | | - | |
| 314 | + | |
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| |||
323 | 329 | | |
324 | 330 | | |
325 | 331 | | |
326 | | - | |
| 332 | + | |
327 | 333 | | |
328 | 334 | | |
329 | 335 | | |
| |||
338 | 344 | | |
339 | 345 | | |
340 | 346 | | |
341 | | - | |
| 347 | + | |
342 | 348 | | |
343 | 349 | | |
344 | 350 | | |
| |||
360 | 366 | | |
361 | 367 | | |
362 | 368 | | |
363 | | - | |
| 369 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
0 commit comments