Skip to content

Commit 00c3312

Browse files
Update src/a2a/utils/task.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent e1f2bdd commit 00c3312

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/a2a/utils/task.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ def new_task(request: Message) -> Task:
2929
raise ValueError('TextPart content cannot be empty')
3030

3131
context_id_str = request.context_id
32-
if context_id_str is not None:
32+
context_id = request.context_id
33+
if context_id is not None:
3334
try:
34-
# Validate that the provided context_id is a valid UUID
35-
uuid.UUID(context_id_str)
36-
context_id = context_id_str
37-
except (ValueError, AttributeError, TypeError):
38-
# Catch a variety of potential issues with the UUID validation
35+
# Validate that the provided context_id is a valid UUID.
36+
uuid.UUID(context_id)
37+
except ValueError:
38+
# Re-raise as ValueError with a more specific message.
3939
raise ValueError(
40-
f"Invalid context_id: '{context_id_str}' is not a valid UUID."
41-
)
40+
f"Invalid context_id: '{context_id}' is not a valid UUID."
41+
) from None
4242
else:
43-
# Generate a new UUID if no context_id is provided
43+
# Generate a new UUID if no context_id is provided.
4444
context_id = str(uuid.uuid4())
4545

4646
return Task(

0 commit comments

Comments
 (0)