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,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 (
You can’t perform that action at this time.
0 commit comments