{"record":{"id":"ab7f6e1451f878f4","repo":"bytedance/deer-flow","slug":"scheduled-task-not-found","errorCode":null,"errorMessage":"Scheduled task not found","messagePattern":"Scheduled task not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"info","filePath":"backend/app/gateway/routers/scheduled_tasks.py","lineNumber":136,"sourceCode":"        title=body.title,\n        prompt=body.prompt,\n        schedule_type=body.schedule_type,\n        schedule_spec=schedule_spec,\n        timezone=body.timezone,\n        next_run_at=next_run_at,\n    )\n\n\n@router.get(\"/scheduled-tasks/{task_id}\")\n@require_permission(\"threads\", \"read\")\nasync def get_scheduled_task(task_id: str, request: Request):\n    repo = get_scheduled_task_repo(request)\n    user = await get_optional_user_from_request(request)\n    if user is None:\n        raise HTTPException(status_code=401, detail=\"Authentication required\")\n    task = await repo.get(task_id, user_id=str(user.id))\n    if task is None:\n        raise HTTPException(status_code=404, detail=\"Scheduled task not found\")\n    return task\n\n\n@router.patch(\"/scheduled-tasks/{task_id}\")\n@require_permission(\"threads\", \"write\")\nasync def update_scheduled_task(task_id: str, request: Request, body: ScheduledTaskUpdateRequest):\n    config = get_config()\n    repo = get_scheduled_task_repo(request)\n    user = await get_optional_user_from_request(request)\n    if user is None:\n        raise HTTPException(status_code=401, detail=\"Authentication required\")\n    existing = await repo.get(task_id, user_id=str(user.id))\n    if existing is None:\n        raise HTTPException(status_code=404, detail=\"Scheduled task not found\")\n    _ensure_task_mutable(existing)\n\n    updates = body.model_dump(exclude_none=True)\n    if \"context_mode\" in updates:","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/scheduled_tasks.py#L118-L154","documentation":"Raised as HTTP 404 by GET /api/scheduled-tasks/{task_id} when repo.get(task_id, user_id=...) returns None — the task id does not exist or belongs to a different user. The repository query is scoped to the requesting user, so foreign tasks are reported as not found.","triggerScenarios":"Fetching a deleted task, a typo'd task id, or a task created by another account; also after the scheduler's retention removes old tasks.","commonSituations":"Stale task id in the UI after deletion; sharing task links between users; polling a completed-and-pruned task.","solutions":["List your tasks via GET /api/scheduled-tasks and use a current task id.","Treat 404 as terminal in polling loops — stop refreshing that task.","Confirm you are authenticated as the user who created the task."],"exampleFix":"// before\nconst task = await api.getTask(id); // throws on 404\n// after\nconst res = await api.getTaskRaw(id);\nif (res.status === 404) { removeTaskFromUi(id); return null; }\nreturn res.data;","handlingStrategy":"try-catch","validationCode":"tasks = requests.get(f\"{BASE}/api/scheduled-tasks\", headers=auth).json()\nowned_ids = {t[\"id\"] for t in tasks}\nif task_id not in owned_ids:\n    remove_task_from_ui(task_id)  # gone or not owned — terminal","typeGuard":"def is_owned_task(tid: str, listed: list[dict]) -> bool:\n    return any(t.get(\"id\") == tid for t in listed)","tryCatchPattern":"resp = requests.get(f\"{BASE}/api/scheduled-tasks/{task_id}\", headers=auth)\nif resp.status_code == 404:\n    remove_task_from_ui(task_id)  # do not retry; do not leak existence assumptions\nelse:\n    resp.raise_for_status()","preventionTips":["Stop refreshing a task card on the first 404.","Use the authenticated creator's account for task links.","Remember 404 covers 'not yours' as well as 'deleted' — design UI copy accordingly."],"tags":["scheduled-tasks","http-404","ownership"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}