Commit a38d438
authored
fix: Add Input Validation for Task IDs in TaskManager (#310)
Previously, the `TaskManager` class in
`a2a/server/tasks/task_manager.py` did not perform any validation on the
`task_id` during initialization. This could lead to silent failures or
inconsistencies in task storage if an invalid ID (such as an empty
string) was provided.
### Impact
Adding this validation improves the robustness of the `TaskManager` and
prevents downstream errors in task management, especially for database
or in-memory stores.
### Fix
In `a2a/server/tasks/task_manager.py`, a check has been added to the
`__init__` method of the `TaskManager` to validate the `task_id`. It now
ensures that if a `task_id` is provided, it is a non-empty string. If
the validation fails, a `ValueError` is raised.
A corresponding unit test has been added to
`tests/server/tasks/test_task_manager.py` to verify that the validation
works as expected.1 parent ecbbb7e commit a38d438
File tree
2 files changed
+17
-0
lines changed- src/a2a/server/tasks
- tests/server/tasks
2 files changed
+17
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
48 | 62 | | |
49 | 63 | | |
50 | 64 | | |
| |||
0 commit comments