Skip to content

fix(server): allow recovery after status event validation fails - #1365

Merged
Iwaniukooo11 merged 5 commits into
a2aproject:mainfrom
HowieYin:fix/task-updater-event-validation
Oct 26, 2026
Merged

Iwaniukooo11 merged 5 commits into
a2aproject:mainfrom
HowieYin:fix/task-updater-event-validation

Conversation

@HowieYin

@HowieYin HowieYin commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

@HowieYin
HowieYin requested a review from a team as a code owner October 21, 2026 11:35
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/tasks/task_updater.py 94.83% 98.31% 🟢 +3.48%
Total 93.01% 93.03% 🟢 +0.02%

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 self-assigned this Oct 21, 2026
@HowieYin HowieYin changed the title fix(server): validate events before marking tasks terminal fix(server): allow recovery after status event validation fails Oct 22, 2026
Comment thread tests/server/tasks/test_task_updater.py Outdated
Comment thread tests/server/tasks/test_task_updater.py Outdated

@Iwaniukooo11 Iwaniukooo11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Iwaniukooo11
Iwaniukooo11 merged commit ca3ef0d into a2aproject:main Oct 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants