fix(co-gahusb): update_task 존재하지 않는 task_id not_found 가드

This commit is contained in:
2026-06-12 07:30:03 +09:00
parent e115eee159
commit d840859fc9
2 changed files with 8 additions and 0 deletions

View File

@@ -106,6 +106,8 @@ async def update_task(r, task_id, status, role, note=None):
if status not in VALID_STATUS: if status not in VALID_STATUS:
raise ValueError(f"invalid status: {status}") raise ValueError(f"invalid status: {status}")
key = TASK_PREFIX + str(task_id) key = TASK_PREFIX + str(task_id)
if not await r.exists(key):
return {"ok": False, "error": "not_found"}
mapping = {"status": status} mapping = {"status": status}
if note is not None: if note is not None:
mapping["note"] = note mapping["note"] = note

View File

@@ -48,3 +48,9 @@ async def test_invalid_status_rejected(r):
tid = (await store.create_task(r, "x", "FE", created_by="Producer"))["task_id"] tid = (await store.create_task(r, "x", "FE", created_by="Producer"))["task_id"]
with pytest.raises(ValueError): with pytest.raises(ValueError):
await store.update_task(r, tid, "bogus", "FE") await store.update_task(r, tid, "bogus", "FE")
async def test_update_nonexistent_task_returns_not_found(r):
res = await store.update_task(r, 999, "done", "FE")
assert res["ok"] is False
assert res["error"] == "not_found"