Commit 5061834
authored
fix: Add Input Validation for Empty Message Content (#327)
# Description
Adding input validation to the `new_task` function in
`a2a/utils/task.py`. The new validation checks if any `part` within a
`Message` contains empty content (e.g., `TextPart(text='')`) and raises
a `ValueError` if it does.
This enhancement improves the system's reliability by preventing the
creation and processing of tasks with invalid or incomplete message
data.
### Changes Made
- Updated the `new_task` function in `src/a2a/utils/task.py` to iterate
through message parts and check for empty content.
- Added a new test case, `test_new_task_invalid_message_empty_content`,
in `tests/utils/test_task.py` to ensure the validation works as
expected.1 parent 73c2e6f commit 5061834
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
148 | 158 | | |
149 | 159 | | |
150 | 160 | | |
| |||
0 commit comments