{"record":{"id":"87b381c6b280e17d","repo":"affaan-m/ECC","slug":"scheduled-task-not-found-schedule-id","errorCode":null,"errorMessage":"Scheduled task not found: {schedule_id}","messagePattern":"Scheduled task not found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":2710,"sourceCode":"                } else if schedules.is_empty() {\n                    println!(\"No scheduled tasks\");\n                } else {\n                    println!(\"Scheduled tasks\");\n                    for schedule in schedules {\n                        println!(\n                            \"#{} {} [{}] | {} | next {}\",\n                            schedule.id,\n                            schedule.task,\n                            schedule.agent_type,\n                            schedule.cron_expr,\n                            schedule.next_run_at.to_rfc3339()\n                        );\n                    }\n                }\n            }\n            ScheduleCommands::Remove { schedule_id } => {\n                if !session::manager::delete_scheduled_task(&db, schedule_id)? {\n                    anyhow::bail!(\"Scheduled task not found: {schedule_id}\");\n                }\n                println!(\"Removed scheduled task {schedule_id}\");\n            }\n            ScheduleCommands::RunDue { limit, json } => {\n                let outcomes = session::manager::run_due_schedules(&db, &cfg, limit).await?;\n                if json {\n                    println!(\"{}\", serde_json::to_string_pretty(&outcomes)?);\n                } else if outcomes.is_empty() {\n                    println!(\"No due scheduled tasks\");\n                } else {\n                    println!(\"Dispatched {} scheduled task(s)\", outcomes.len());\n                    for outcome in outcomes {\n                        println!(\n                            \"#{} -> {} | {} | next {}\",\n                            outcome.schedule_id,\n                            short_session(&outcome.session_id),\n                            outcome.task,\n                            outcome.next_run_at.to_rfc3339()","sourceCodeStart":2692,"sourceCodeEnd":2728,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L2692-L2728","documentation":"The `schedule remove` CLI command calls `session::manager::delete_scheduled_task`, which returns false when no scheduled task with the given ID exists in the state store; the command then bails with a not-found message naming the ID. This distinguishes \"nothing to delete\" from a successful removal.","triggerScenarios":"Running the schedule remove command with a `schedule_id` that was already removed, never created, or mistyped.","commonSituations":"Re-running cleanup scripts that delete tasks idempotently, stale IDs from a wiped or different database file, or copy-pasted IDs with typos.","solutions":["Verify the schedule ID exists (list scheduled tasks) before removing.","Check you are pointing at the same state store/database the task was created in.","Make removal scripts idempotent by ignoring this error when the task is already gone."],"exampleFix":"// before\nif !session::manager::delete_scheduled_task(&db, id)? {\n    anyhow::bail!(\"Scheduled task not found: {id}\");\n}\n// after\nif !session::manager::delete_scheduled_task(&db, id)? {\n    eprintln!(\"Scheduled task not found (already removed): {id}\");\n    return Ok(()); // treat as idempotent success\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = remove_schedule(&db, id) {\n    if e.to_string().contains(\"Scheduled task not found\") {\n        eprintln!(\"Task {} already removed; treating as success\", id);\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["List scheduled tasks to confirm the ID before removing","Confirm the command uses the same database/state store the task was created in","Write cleanup scripts to tolerate already-deleted IDs"],"tags":["cli","not-found","persistence"],"backgroundTag":"resource-not-found","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}