{"record":{"id":"49a817714fb9402d","repo":"bytedance/deer-flow","slug":"unsupported-schedule-type","errorCode":null,"errorMessage":"Unsupported schedule_type","messagePattern":"Unsupported schedule_type","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"warning","filePath":"backend/app/gateway/routers/scheduled_tasks.py","lineNumber":85,"sourceCode":"\n@router.post(\"/scheduled-tasks\")\n@require_permission(\"threads\", \"write\")\nasync def create_scheduled_task(request: Request, body: ScheduledTaskCreateRequest):\n    config = get_config()\n    repo = get_scheduled_task_repo(request)\n    thread_store = get_thread_store(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    if body.context_mode not in {\"fresh_thread_per_run\", \"reuse_thread\"}:\n        raise HTTPException(status_code=422, detail=\"Unsupported context_mode\")\n    if body.context_mode == \"reuse_thread\":\n        if not body.thread_id:\n            raise HTTPException(status_code=422, detail=\"reuse_thread requires thread_id\")\n        if not await thread_store.check_access(body.thread_id, str(user.id), require_existing=True):\n            raise HTTPException(status_code=404, detail=\"Thread not found\")\n    if body.schedule_type not in {\"once\", \"cron\"}:\n        raise HTTPException(status_code=422, detail=\"Unsupported schedule_type\")\n\n    schedule_spec = dict(body.schedule_spec)\n    try:\n        validate_timezone(body.timezone)\n        if body.schedule_type == \"cron\":\n            raw_cron = schedule_spec.get(\"cron\")\n            if not isinstance(raw_cron, str):\n                raise HTTPException(status_code=422, detail=\"cron schedule requires schedule_spec.cron\")\n            schedule_spec[\"cron\"] = normalize_cron_expression(raw_cron)\n        next_run_at = compute_next_run_at(\n            body.schedule_type,\n            schedule_spec,\n            body.timezone,\n            now=datetime.now(UTC),\n        )\n    except ValueError as exc:\n        raise HTTPException(status_code=422, detail=str(exc)) from exc\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/scheduled_tasks.py#L67-L103","documentation":"Raised as HTTP 422 by POST /api/scheduled-tasks when schedule_type is not 'once' or 'cron'. Like context_mode, it is a string validated in-handler rather than a Pydantic enum, so arbitrary strings reach this branch.","triggerScenarios":"Creating a task with schedule_type such as 'interval', 'recurring', or a typo like 'Once'.","commonSituations":"Clients expecting interval schedules the backend does not support; case mismatches; payload schema drift.","solutions":["Use exactly 'once' (single future run) or 'cron' (recurring).","For recurring schedules, express the pattern as a cron expression in schedule_spec.cron.","Check the OpenAPI schema at /docs for the accepted request shape."],"exampleFix":"// before\n{ \"schedule_type\": \"interval\", \"schedule_spec\": { \"every_minutes\": 5 } }\n// after\n{ \"schedule_type\": \"cron\", \"schedule_spec\": { \"cron\": \"*/5 * * * *\" } }","handlingStrategy":"validation","validationCode":"VALID_SCHEDULE_TYPES = {\"once\", \"cron\"}\nassert body[\"schedule_type\"] in VALID_SCHEDULE_TYPES, f\"use one of {VALID_SCHEDULE_TYPES}\"","typeGuard":"type ScheduleType = \"once\" | \"cron\";\nconst isScheduleType = (v: unknown): v is ScheduleType => v === \"once\" || v === \"cron\";","tryCatchPattern":null,"preventionTips":["Constrain the schedule-type control to a two-option enum in the UI.","Express recurring schedules as cron strings, not custom interval objects."],"tags":["scheduled-tasks","validation","http-422","cron"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}