affaan-m/ECC · error

Scheduled task not found: {schedule_id}

Error message

Scheduled task not found: {schedule_id}

What it means

Thrown by `schedule remove` when `session::manager::delete_scheduled_task(&db, schedule_id)` returns `false`, indicating no row matched the given schedule ID for deletion. The manager signals "not found" via a boolean rather than an error, and the CLI promotes it to a bail so the user knows nothing was removed. The success path prints `Removed scheduled task {schedule_id}`.

Source

Thrown at ecc2/src/main.rs:2710

                } else if schedules.is_empty() {
                    println!("No scheduled tasks");
                } else {
                    println!("Scheduled tasks");
                    for schedule in schedules {
                        println!(
                            "#{} {} [{}] | {} | next {}",
                            schedule.id,
                            schedule.task,
                            schedule.agent_type,
                            schedule.cron_expr,
                            schedule.next_run_at.to_rfc3339()
                        );
                    }
                }
            }
            ScheduleCommands::Remove { schedule_id } => {
                if !session::manager::delete_scheduled_task(&db, schedule_id)? {
                    anyhow::bail!("Scheduled task not found: {schedule_id}");
                }
                println!("Removed scheduled task {schedule_id}");
            }
            ScheduleCommands::RunDue { limit, json } => {
                let outcomes = session::manager::run_due_schedules(&db, &cfg, limit).await?;
                if json {
                    println!("{}", serde_json::to_string_pretty(&outcomes)?);
                } else if outcomes.is_empty() {
                    println!("No due scheduled tasks");
                } else {
                    println!("Dispatched {} scheduled task(s)", outcomes.len());
                    for outcome in outcomes {
                        println!(
                            "#{} -> {} | {} | next {}",
                            outcome.schedule_id,
                            short_session(&outcome.session_id),
                            outcome.task,
                            outcome.next_run_at.to_rfc3339()

View on GitHub (pinned to 01e15490f0)

Solutions

  1. List current schedules with `ecc schedule list` to find a valid ID.
  2. If the task was already removed, treat the error as success and skip.
  3. Confirm the state store path matches the workspace where the schedule was created.

Example fix

// before
ecc schedule remove 9999

// after
ecc schedule list              # confirm id
ecc schedule remove <valid-id>
Defensive patterns

Strategy: validation

Validate before calling

// Idempotent remove in calling code
fn safe_remove(db: &StateStore, id: i64) -> Result<()> {
    if session::manager::delete_scheduled_task(db, id)? {
        println!("removed schedule {id}");
    } else {
        println!("schedule {id} already absent");
    }
    Ok(())
}

Try / catch

match session::manager::delete_scheduled_task(&db, schedule_id) {
    Ok(true) => println!("Removed scheduled task {schedule_id}"),
    Ok(false) => eprintln!("Scheduled task not found: {schedule_id} (nothing to remove)"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Running `ecc schedule remove <id>` with an ID that does not exist in the schedules table. Re-running a removal after the task was already deleted. Passing an ID from a different state store or a typo in the numeric ID.

Common situations: Idempotency assumptions — calling remove twice. Stale schedule IDs after a DB reset. Operating on the wrong workspace whose schedule table is empty.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/87b381c6b280e17d. Report an issue: GitHub.