-
Notifications
You must be signed in to change notification settings - Fork 429
fix: raise ValueError on append to nonexistent artifact #1040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -429,6 +429,7 @@ def test_append_artifact_to_task(): | |||||
| assert len(task.artifacts[1].parts) == 1 | ||||||
|
|
||||||
| # Test appending part to a task that does not have a matching artifact | ||||||
| # raises ValueError instead of silently dropping the chunk (#1038) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| non_existing_artifact_with_parts = Artifact( | ||||||
| artifact_id='artifact-456', parts=[Part(text='Part 1')] | ||||||
| ) | ||||||
|
|
@@ -438,7 +439,9 @@ def test_append_artifact_to_task(): | |||||
| task_id='123', | ||||||
| context_id='123', | ||||||
| ) | ||||||
| append_artifact_to_task(task, append_event_5) | ||||||
| with pytest.raises(ValueError, match='append=True but no artifact with id'): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the test to assert
Suggested change
References
|
||||||
| append_artifact_to_task(task, append_event_5) | ||||||
| # Artifacts unchanged — the bad chunk was not silently added | ||||||
| assert len(task.artifacts) == 2 | ||||||
| assert len(task.artifacts[0].parts) == 2 | ||||||
| assert len(task.artifacts[1].parts) == 1 | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using
InvalidParamsErrorinstead of the built-inValueError. Sinceappend_artifact_to_taskis part of the task event processing pipeline, using the project's customA2AErrorsubclasses ensures that the error is correctly caught and mapped to a structured protocol response. Note that per repository rules, exception classes must be raised directly without instantiation.References