Repository navigation
fix(server-common): refuse artifact updates on a task in a final state (no artifact persisted on, or handed over for, a final task) - #1392
Open
joulook wants to merge 1 commit into
Conversation
TaskManager.saveTaskEvent appended an artifact to a task whatever its state. An agent that was still running after its task had been canceled could therefore add an artifact to the CANCELED task: the artifact was stored on the task and handed to the push notification sender after CancelTask had answered CANCELED. A task in a final state is now treated as immutable for artifacts, as it already is for status changes. The artifact update is refused with the same A2AServerException and InternalError that validateStateTransition uses, so the event bus processor distributes the error and pushes nothing. This changes behaviour: an artifact update for a completed, failed or canceled task now fails instead of being stored. It does not make the cancel wait for its own CANCELED push notification, which is still sent asynchronously. Fixes: a2aproject#1391
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1391.
TaskManager.saveTaskEvent(TaskArtifactUpdateEvent, ...)now refuses an artifact for a task whose state is final,with the same
A2AServerException/InternalErrorasvalidateStateTransitionuses for a status change. The eventbus processor then distributes the error and pushes nothing (
MainEventBusProcessor.java:309-318, 324). An agent thatkeeps running after its task was canceled can no longer add an artifact to the CANCELED task or have one handed to the
push sender for it. An artifact handed over before the cancel can still be POSTed after it (see Scope).
Behaviour change: an artifact update for a completed/failed/canceled task now fails instead of being stored.
Scope: this change removes the post-terminal artifact (the model's property P', where the CANCELED status itself is
exempt). It does not make the cancel wait for its own CANCELED push: the push chain is asynchronous
(
MainEventBusProcessor.java:475-505) andonCancelTaskdoes not wait for it, so CANCELED may still be handed to thepush sender after the return (the test exempts CANCELED for this reason). Our model's second fix, part (b) (the cancel
waits for CANCELED on its tap and for the push chain), is not in this PR.
Tests (on main bc7f9d7, branch commit 600e6200, which adds the test):
CancelLateArtifactPushTest(@RepeatedTest(5), 3 runs):15 of 15 trials fail on main, 0 of 15 with the change. The server-common suite with the change: 677 tests, 1 failure,
DefaultRequestHandlerBuilderAuthorizationTest.emptyTaskIdWithoutEffectiveCardIsInvalid, which fails on main too inthe same offline build (only server-common built; sibling modules from cached snapshot jars).
Model (K = 2): with this change no artifact is handed to the push sender after the acknowledgement (0 of 298,802
executions, CANCELED exempt). At the POST, the asynchronous chain can still deliver an artifact handed over before the
cancel after the acknowledgement (63,505 of 2,225,095); part (b) removes that too (0 of 716,174). The native test
covers the post-terminal artifact only (the artifact is emitted after the return).
Not in this PR (noted in the issue thread if useful):
onCancelTaskreturns on the first event of any kind on its tap(
ResultAggregator.java:155-171), not on CANCELED as the comment atDefaultRequestHandler.java:785-787says, andit does not wait for the task's push chain, so CANCELED itself may be pushed after the return. An event processed
just before CANCELED can make it answer TaskNotCancelableError while the task then ends CANCELED
(
CancelNotCancelableYetCanceledTest, a separate observation: 15 of 15 trials, with or without this change).Found with. We are a research team at MPI-SWS building Daavar, a conformance checker for distributed protocol
implementations. The post-terminal artifact was found by a JMC model of the cancel path with an adversary client and
confirmed natively on the SDK. This PR was prepared with AI assistance and reviewed by us.
Reproduce with Daavar (8161b57)
Printed (fresh clone at 8161b57, 2026-12-05): with this change, at the hand-off,
execs=298802 blocked=0,assertions: 0 execution(s) had a failed assertion(no artifact handed over after the acknowledgement); at the POST,execs=2161590 blocked=63505,assertions: 63505 execution(s) had a failed assertion(an artifact handed over beforethe cancel is still POSTed after it: the window this PR leaves).
A security issue of the effect-after-revocation kind (an effect follows the acknowledged cancel) under our stated authority contract; no MUST of A2A v1.0.0 is broken.