tinyhumansai/openhuman · error

Cron job '{id}' not found

Error message

Cron job '{id}' not found

What it means

remove_job executes DELETE FROM cron_jobs WHERE id = ?1 and checks the affected-row count; zero rows means no such job existed, so it bails instead of reporting success. This makes delete outcomes explicit: callers can distinguish 'removed' from 'nothing there'.

Source

Thrown at src/openhuman/cron/store.rs:280

        )?;

        let mut rows = stmt.query(params![job_id])?;
        if let Some(row) = rows.next()? {
            map_cron_job_row(row).map_err(Into::into)
        } else {
            anyhow::bail!("Cron job '{job_id}' not found")
        }
    })
}

pub fn remove_job(config: &Config, id: &str) -> Result<()> {
    let changed = with_connection(config, |conn| {
        conn.execute("DELETE FROM cron_jobs WHERE id = ?1", params![id])
            .context("Failed to delete cron job")
    })?;

    if changed == 0 {
        anyhow::bail!("Cron job '{id}' not found");
    }

    println!("✅ Removed cron job {id}");
    Ok(())
}

/// Deletes every cron job in the workspace. Returns the number of rows removed.
///
/// Intended for the `openhuman.test_reset` RPC used by E2E specs to wipe state
/// between tests without restarting the sidecar. The cron scheduler picks up
/// the empty table on its next tick — no in-memory cache to invalidate.
pub fn clear_all_jobs(config: &Config) -> Result<usize> {
    let removed = with_connection(config, |conn| {
        conn.execute("DELETE FROM cron_jobs", params![])
            .context("Failed to clear cron jobs")
    })?;
    log::info!("[cron] cleared all cron jobs (removed {removed} rows)");
    Ok(removed)

View on GitHub (pinned to 7491200858)

Solutions

  1. Confirm via cron list whether the job still exists; if it is already gone, treat the outcome as success
  2. Re-copy the id from a fresh listing if the job exists under a different id
  3. Check workspace/user profile if the listing itself is empty

Example fix

// before
remove_job(&config, id)?; // hard error on double-delete

// after
match remove_job(&config, id) {
    Ok(()) => println!("removed"),
    Err(e) if e.to_string().contains("not found") => println!("already gone"),
    Err(e) => return Err(e),
}
Defensive patterns

Strategy: try-catch

Try / catch

For idempotent deletes, swallow the not-found branch and report success: match remove_job(...); on Err(e) whose message contains 'not found', return Ok — propagate every other error.

Prevention

When it happens

Trigger: Deleting an already-deleted job — double-click, retried request, re-run script; a wrong or stale id; a different workspace's cron.db.

Common situations: UI retry after a timeout where the first DELETE actually succeeded; idempotent cleanup scripts re-run; concurrent sessions deleting the same job.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/a4cf6a3ac6275277. Report an issue: GitHub.