Repository navigation
Commit ca3ef0d
fix(server): allow recovery after status event validation fails (#1365)
## Problem
`TaskUpdater.update_status()` sets the terminal flag before constructing
the status event. An invalid timestamp, message, or metadata can then
raise an exception before anything reaches the queue.
For example, after a `COMPLETED` update with an invalid timestamp,
calling `failed()` to report the error raises a `RuntimeError` saying
the task is already terminal. The updater never published the completion
event.
## Fix
Construct the complete `TaskStatusUpdateEvent` before setting the
terminal flag, so a construction error leaves the updater able to report
a failure. The flag is still set under the existing lock, before
enqueueing.
## Tests
- Add recovery tests for invalid timestamps across all four terminal
states and for invalid metadata.
- Verify that `DefaultRequestHandlerV2` returns and stores a `FAILED`
task after the agent catches a status validation error.
Local validation on Python 3.10:
- `./scripts/lint.sh` passes (Ruff, formatting, and ty).
- `UV_OFFLINE=1 uv run pytest --cov=a2a --cov-report=term
--cov-fail-under=88`: **2,312 passed, 183 skipped, 3 xfailed, 1
xpassed**, with **92.95% coverage**.
The 183 skips are 182 PostgreSQL/MySQL tests without configured test
databases and one SQLite row-lock test. The existing xfail/xpass cases
reference #869. The first online runs hit the cross-version fixture's
three-second startup timeout while uv downloaded or resolved legacy SDK
dependencies; the full run passes with those dependencies cached and
offline mode enabled.
GitHub CI for the updated commit is pending.
---------
Co-authored-by: Mateusz Iwaniuk <45974414+Iwaniukooo11@users.noreply.github.com>1 parent c70403a commit ca3ef0d
3 files changed
Lines changed: 109 additions & 9 deletions
File tree
- src/a2a/server/tasks
- tests/server
- request_handlers
- tasks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
111 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
132 | 192 | | |
133 | 193 | | |
134 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
118 | 159 | | |
119 | 160 | | |
120 | 161 | | |
| |||
0 commit comments