From 58209ad2bf67a0d814b9c74fd49b7d3a171e33a0 Mon Sep 17 00:00:00 2001 From: TheDancingDeveloper Date: Tue, 11 Aug 2026 09:26:30 +0000 Subject: [PATCH] fix: implement mode=get_scripts (#74) get_scripts is a real top-level SABnzbd API mode (sabnzbd/api.py::_api_table["get_scripts"]) that fell through dispatch_mode's default arm as "Unknown mode". RustNZB doesn't support post-processing scripts, so ["None"] -- the same value real SABnzbd reports with no scripts configured -- is the correct permanent response. Clients that fetch categories and scripts together to populate an add-download dialog may abort populating the whole dialog (category picker included) if either call errors, so this is a plausible second contributor to #65 alongside #73. --- crates/nzb-web/src/sabnzbd_compat.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/nzb-web/src/sabnzbd_compat.rs b/crates/nzb-web/src/sabnzbd_compat.rs index 399e1dc..cdb661e 100644 --- a/crates/nzb-web/src/sabnzbd_compat.rs +++ b/crates/nzb-web/src/sabnzbd_compat.rs @@ -378,6 +378,12 @@ fn dispatch_mode(state: &AppState, mode: &str, req: &SabApiRequest) -> Json handle_get_cats(state), + // RustNZB doesn't support post-processing scripts, so this is the + // permanent, correct response -- it matches what real SABnzbd + // reports when no script directory / scripts are configured + // (sabnzbd/api.py::_api_get_scripts -> filesystem.py::list_scripts). + "get_scripts" => Json(serde_json::json!({ "scripts": ["None"] })), + "change_cat" => handle_change_cat(state, req), "rename" => handle_rename(state, req), @@ -2148,4 +2154,17 @@ mod tests { sab_contract::golden(&contents); } } + + /// Real SABnzbd's `mode=get_scripts` always answers with at least + /// `["None"]` (sabnzbd/api.py::_api_get_scripts, + /// filesystem.py::list_scripts) -- clients that fetch categories and + /// scripts together to populate an "add download" dialog may fail to + /// populate the whole dialog if this call errors, as it previously did. + #[tokio::test] + async fn get_scripts_reports_none_when_unsupported() { + let test_state = test_state(); + let req = SabApiRequest::default(); + let response = dispatch_mode(&test_state.state, "get_scripts", &req).0; + assert_eq!(response["scripts"], serde_json::json!(["None"])); + } }