From 59d4c043b03b45564b27624edb24851c5ccc9c09 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sun, 7 Jun 2026 21:02:57 +0200 Subject: [PATCH] fix(http): F-Q-008 add HttpError::InvalidArgs for user-input validation failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http_service::run mapped `Method::from_bytes` failure on a user-supplied HTTP method to HttpError::Backend with format!("invalid method: {}", …). Same for HeaderName/HeaderValue validation in build_headers. But that's user input, not a backend problem — misclassifying as Backend corrupts retry policies (operators may retry "backend" but not "invalid input"). Add a new HttpError::InvalidArgs(String) variant. Reroute the three validation paths in http_service (method, header name, header value) to emit InvalidArgs instead of Backend. The executor-side `map_http_err` uses Display, so the new variant surfaces to scripts as "http: invalid method: …" — same format, more structured behind it. AUDIT.md anchor: F-Q-008. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/manager-core/src/http_service.rs | 8 +++++--- crates/shared/src/http.rs | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/manager-core/src/http_service.rs b/crates/manager-core/src/http_service.rs index b8fa1c8..818c5f3 100644 --- a/crates/manager-core/src/http_service.rs +++ b/crates/manager-core/src/http_service.rs @@ -205,8 +205,9 @@ impl HttpServiceImpl { /// Core request path: validate, build headers, follow redirects /// manually, read the response body with a cap. async fn run(&self, req: HttpRequest) -> Result { + // F-Q-008: bad method is user input, not a backend problem. let method = Method::from_bytes(req.method.as_bytes()) - .map_err(|_| HttpError::Backend(format!("invalid method: {}", req.method)))?; + .map_err(|_| HttpError::InvalidArgs(format!("invalid method: {}", req.method)))?; let mut current = url::Url::parse(&req.url) .map_err(|e| HttpError::InvalidUrl(format!("{}: {e}", req.url)))?; @@ -336,10 +337,11 @@ fn build_headers(req: &HttpRequest, _url: &url::Url) -> Result