From abad9b9cfd31fade87e788922f081f9d95d74c77 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Tue, 25 Aug 2026 08:33:47 +0100 Subject: [PATCH] fix(arr): name the field, not a reply, in the 422 The backend's Malformed Display describes an answer that came back wrong. Nothing is sent while validating a settings write, so only the reason belongs in the message. --- crates/arr-api/src/subtitle_settings.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/arr-api/src/subtitle_settings.rs b/crates/arr-api/src/subtitle_settings.rs index 46b0622..659e714 100644 --- a/crates/arr-api/src/subtitle_settings.rs +++ b/crates/arr-api/src/subtitle_settings.rs @@ -107,8 +107,16 @@ impl SubtitleSettingsInput { // quietly stopped working. Validated whether or not this build // compiled the backend in — the column exists either way. if let Some(base_url) = blank_to_none(self.openai_base_url.as_deref()) { - arr_subs::OpenAiEndpoint::new(Some(base_url), None) - .map_err(|error| format!("openai_base_url: {error}"))?; + arr_subs::OpenAiEndpoint::new(Some(base_url), None).map_err(|error| { + // The backend's own Display talks about a reply that came + // back wrong; here nothing was ever sent, so only the + // reason belongs in the message. + let reason = match &error { + arr_subs::translate::Error::Malformed { detail, .. } => detail.clone(), + other => other.to_string(), + }; + format!("openai_base_url: {reason}") + })?; } Ok(()) } @@ -592,12 +600,9 @@ mod tests { .expect("put settings"); assert_eq!(response.status(), StatusCode::UNPROCESSABLE_ENTITY); let body: serde_json::Value = response.json().await.expect("error json"); - assert!( - body["error"] - .as_str() - .expect("error string") - .starts_with("openai_base_url:"), - "got {body}" + assert_eq!( + body["error"], "openai_base_url: bad base URL: relative URL without a base", + "the message names the field and the reason, not a reply that never came" ); }