From b66c07a8c7859345b33273f872791f791df10659 Mon Sep 17 00:00:00 2001 From: Anoop Narang Date: Tue, 30 Jun 2026 12:42:02 +0530 Subject: [PATCH] fix(jobs): accept managed_load as --job-type filter (#160) The jobs list crash on managed_load rows was already resolved by the SDK 0.6.0 bump (c803d22), whose JobType enum carries the ManagedLoad variant the server emits for `databases load`. This closes the remaining gap: the CLI's --job-type filter still rejected managed_load because both the clap value_parser and parse_job_type were stale (last touched when the SDK only had 4 user-facing types). managed_load is intentionally customer-visible: runtimedb's is_maintenance() (#740) hides only the 5 internal maintenance jobs from listings, and managed_load is deliberately not among them. Displayed TYPE stays the raw token, consistent with the other job types. Adds regression tests proving a managed_load row deserializes and that the filter token maps to JobType::ManagedLoad. --- src/command.rs | 2 +- src/jobs.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/command.rs b/src/command.rs index 26df21a..938feb3 100644 --- a/src/command.rs +++ b/src/command.rs @@ -381,7 +381,7 @@ pub enum JobsCommands { /// List background jobs (shows active jobs by default) List { /// Filter by job type - #[arg(long, value_parser = ["data_refresh_table", "data_refresh_connection", "create_index"])] + #[arg(long, value_parser = ["data_refresh_table", "data_refresh_connection", "create_index", "managed_load"])] job_type: Option, /// Filter by status diff --git a/src/jobs.rs b/src/jobs.rs index 8dcdb33..1d4cb3f 100644 --- a/src/jobs.rs +++ b/src/jobs.rs @@ -41,6 +41,7 @@ fn parse_job_type(s: &str) -> Option { "data_refresh_table" => Some(JobType::DataRefreshTable), "data_refresh_connection" => Some(JobType::DataRefreshConnection), "create_index" => Some(JobType::CreateIndex), + "managed_load" => Some(JobType::ManagedLoad), _ => None, } } @@ -103,6 +104,37 @@ pub fn get(job_id: &str, workspace_id: &str, format: &str) { } } +#[cfg(test)] +mod tests { + use super::*; + use hotdata::models::ListJobsResponse; + + // Regression for #160: a `managed_load` row must deserialize, not blow up + // the whole `jobs list` response. Proves SDK 0.6.0's JobType carries the + // variant the server emits for `databases load`. + #[test] + fn list_response_with_managed_load_deserializes() { + let body = r#"{ + "jobs": [ + { + "id": "job_1", + "job_type": "managed_load", + "status": "succeeded", + "attempts": 1, + "created_at": "2026-06-18T06:00:00Z" + } + ] + }"#; + let resp: ListJobsResponse = serde_json::from_str(body).expect("managed_load must parse"); + assert_eq!(resp.jobs[0].job_type, JobType::ManagedLoad); + } + + #[test] + fn parse_job_type_accepts_managed_load() { + assert_eq!(parse_job_type("managed_load"), Some(JobType::ManagedLoad)); + } +} + fn fetch_jobs( api: &Api, job_type: Option<&str>,