@@ -535,3 +535,29 @@ def test_post_complete_and_uncomplete_keep_status_in_sync(self, fresh_db, client
535535 assert task .status == "open"
536536 assert task .completed_by_agent_id is None
537537 db .close ()
538+
539+
540+ class TestTaskContentValidation :
541+ """Task content must contain non-whitespace text."""
542+
543+ @pytest .mark .parametrize ("content" , ["" , " " , "\n \t " ])
544+ def test_create_task_rejects_blank_content (self , fresh_db , client , content ):
545+ _ , agent_key = make_agent (fresh_db , "worker" )
546+
547+ response = client .post ("/api/tasks" , json = {"content" : content }, headers = auth (agent_key ))
548+
549+ assert response .status_code == 422
550+ assert "content" in response .text .lower ()
551+
552+ @pytest .mark .parametrize ("content" , ["" , " " , "\n \t " ])
553+ def test_update_task_rejects_blank_content (self , fresh_db , client , content ):
554+ _ , agent_key = make_agent (fresh_db , "worker" )
555+
556+ created = client .post ("/api/tasks" , json = {"content" : "valid" }, headers = auth (agent_key ))
557+ assert created .status_code == 200
558+ task_id = created .json ()["id" ]
559+
560+ response = client .put (f"/api/tasks/{ task_id } " , json = {"content" : content }, headers = auth (agent_key ))
561+
562+ assert response .status_code == 422
563+ assert "content" in response .text .lower ()
0 commit comments