Repository navigation
Commit af9437f
fix(compat): return result: null for v0.3 pushNotificationConfig/delete (#1481)
# Description
With `enable_v0_3_compat=True`, a successful v0.3
`tasks/pushNotificationConfig/delete` was answered with `{"id": 1,
"jsonrpc": "2.0"}`, with neither `result` nor `error`. JSON-RPC 2.0 §5
requires `result` on success, the v0.3 schema requires `result: null`
here, and the SDK's own v0.3 response type rejects the body. The v1.0
JSON-RPC path already returns `"result": null`.
**Cause:** `JSONRPC03Adapter._process_non_streaming_request` dumps the
response with `exclude_none=True`, which also drops the `None` result of
the delete success response.
**Fix:** keep `exclude_none=True` (so unset optional fields stay out)
and put `result` back with `content.setdefault('result', None)`. Only
success responses go through this code path, so error responses are
unaffected; for every other method `result` is already set.
## Testing
New test in `tests/compat/v0_3/test_jsonrpc_app_compat.py`.
Before the fix:
```
AssertionError: assert {'id': '5', 'jsonrpc': '2.0'} == {'id': '5', 'jsonrpc': '2.0', 'result': None}
```
After:
```
$ pytest tests/compat/v0_3 -k delete
1 passed
```
Full suite on main (c16cab1):
```
$ pytest tests --ignore=tests/integration/cross_version
2618 passed, 215 skipped, 4 xfailed, 1 xpassed
```
`ruff check`, `ruff format` and `ty check` pass on the changed files.
- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)
Fixes #1480 🦕
Co-authored-by: Mateusz Iwaniuk <45974414+Iwaniukooo11@users.noreply.github.com>1 parent a01d990 commit af9437f
2 files changed
Lines changed: 27 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 243 | + | |
| 244 | + | |
247 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
168 | 188 | | |
169 | 189 | | |
170 | 190 | | |
| |||
0 commit comments