Skip to content

Commit 6b1db9a

Browse files
Shiven0504gefjon
andauthored
Include full error chain in procedure HTTP request errors (#4610)
Summary When an HTTP request fails inside a procedure, the error message only shows something like "error sending request for url (https://...)" with no details about what actually went wrong. This change walks the full error chain so the message includes the root cause — things like DNS failures, connection refused, timeouts, etc. - Before: error sending request for url (https://httpbin.org/get) - After: error sending request for url (https://httpbin.org/get): error trying to connect: dns error: failed to lookup address information: Fixes #4608 Test plan - Trigger an HTTP failure in a procedure and check that the error message now shows the actual reason for the failure - Existing tests should still pass since this only changes error formatting Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
1 parent f8d6d76 commit 6b1db9a

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

crates/core/src/host/instance_env.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,18 @@ impl InstanceEnv {
857857
err
858858
}
859859

860-
fn http_error<E: ToString>(err: E) -> NodesError {
861-
NodesError::HttpError(err.to_string())
860+
fn http_error<E: std::error::Error>(err: E) -> NodesError {
861+
// Include the full error chain, not just the top-level message.
862+
// `reqwest::Error` wraps underlying causes (DNS failure, connection refused,
863+
// timeout, TLS errors, etc.) which are essential for debugging.
864+
use std::fmt::Write;
865+
let mut message = err.to_string();
866+
let mut source = err.source();
867+
while let Some(cause) = source {
868+
write!(message, ": {cause}").unwrap();
869+
source = cause.source();
870+
}
871+
NodesError::HttpError(message)
862872
}
863873

864874
// Then convert the request into an `http::Request`, a semi-standard "lingua franca" type in the Rust ecosystem,
@@ -888,7 +898,7 @@ impl InstanceEnv {
888898

889899
// Check if we have a blocked IP address, since IP literals bypass DNS resolution.
890900
if is_blocked_ip_literal(reqwest.url()) {
891-
return Err(http_error(BLOCKED_HTTP_ADDRESS_ERROR));
901+
return Err(NodesError::HttpError(BLOCKED_HTTP_ADDRESS_ERROR.to_string()));
892902
}
893903

894904
let redirect_policy = reqwest::redirect::Policy::custom(|attempt| {

0 commit comments

Comments
 (0)