File tree Expand file tree Collapse file tree 2 files changed +2
-32
lines changed Expand file tree Collapse file tree 2 files changed +2
-32
lines changed Original file line number Diff line number Diff line change @@ -28,22 +28,10 @@ def new_task(request: Message) -> Task:
2828 if isinstance (part .root , TextPart ) and not part .root .text :
2929 raise ValueError ('TextPart content cannot be empty' )
3030
31- context_id_str = request .context_id
32- if context_id_str is not None :
33- try :
34- uuid .UUID (context_id_str )
35- context_id = context_id_str
36- except (ValueError , AttributeError , TypeError ) as e :
37- raise ValueError (
38- f"Invalid context_id: '{ context_id_str } ' is not a valid UUID."
39- ) from e
40- else :
41- context_id = str (uuid .uuid4 ())
42-
4331 return Task (
4432 status = TaskStatus (state = TaskState .submitted ),
45- id = ( request .task_id if request . task_id else str (uuid .uuid4 () )),
46- context_id = context_id ,
33+ id = request .task_id or str (uuid .uuid4 ()),
34+ context_id = request . context_id or str ( uuid . uuid4 ()) ,
4735 history = [request ],
4836 )
4937
Original file line number Diff line number Diff line change @@ -188,24 +188,6 @@ def test_completed_task_invalid_artifact_type(self):
188188 history = [],
189189 )
190190
191- def test_new_task_with_invalid_context_id (self ):
192- """Test that new_task raises a ValueError for various invalid context_id formats."""
193- invalid_ids = ['not-a-uuid' , '' ]
194- for invalid_id in invalid_ids :
195- with self .subTest (invalid_id = invalid_id ):
196- with pytest .raises (
197- ValueError ,
198- match = f"Invalid context_id: '{ invalid_id } ' is not a valid UUID." ,
199- ):
200- new_task (
201- Message (
202- role = Role .user ,
203- parts = [Part (root = TextPart (text = 'test message' ))],
204- message_id = str (uuid .uuid4 ()),
205- context_id = invalid_id ,
206- )
207- )
208-
209191
210192if __name__ == '__main__' :
211193 unittest .main ()
You can’t perform that action at this time.
0 commit comments