File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,18 +29,15 @@ def new_task(request: Message) -> Task:
2929 raise ValueError ('TextPart content cannot be empty' )
3030
3131 context_id_str = request .context_id
32- context_id = request .context_id
33- if context_id is not None :
32+ if context_id_str is not None :
3433 try :
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.
34+ uuid .UUID (context_id_str )
35+ context_id = context_id_str
36+ except (ValueError , AttributeError , TypeError ) as e :
3937 raise ValueError (
40- f"Invalid context_id: '{ context_id } ' is not a valid UUID."
41- ) from None
38+ f"Invalid context_id: '{ context_id_str } ' is not a valid UUID."
39+ ) from e
4240 else :
43- # Generate a new UUID if no context_id is provided.
4441 context_id = str (uuid .uuid4 ())
4542
4643 return Task (
You can’t perform that action at this time.
0 commit comments