Commit a7ed7ef
fix: Add Input Validation for Task Context IDs in new_task Function (#340)
# Description
This update addresses an issue where the `new_task` function in
`src/a2a/utils/task.py` did not validate the format of the `context_id`
when it was provided. Invalid or malformed `context_id` values, such as
empty strings or non-UUID strings, were not being properly handled,
which could lead to downstream errors.
The changes in this PR introduce a validation check to ensure that any
provided `context_id` is a valid UUID. If the `context_id` is invalid, a
`ValueError` is raised. If no `context_id` is provided, a new UUID is
generated as before.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent 4d5b92c commit a7ed7ef
2 files changed
+32
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
191 | 209 | | |
192 | 210 | | |
193 | 211 | | |
0 commit comments