Skip to content

fix: improve agent request error handling with structured details - #226

Merged
mintybasil merged 1 commit into
mintybasil:mainfrom
zeroklaw:fix/improve-agent-request-error-handling
Jun 29, 2026
Merged

fix: improve agent request error handling with structured details#226
mintybasil merged 1 commit into
mintybasil:mainfrom
zeroklaw:fix/improve-agent-request-error-handling

Conversation

@zeroklaw

Copy link
Copy Markdown
Collaborator

Summary

Closes #225

The error message reported in issue #225 was:

20:10:55 ERROR yoke::dispatcher: Workflow execution failed workflow=implement_issue.toml repo=mintybasil/yoke event_id=issue-216 error=Execution failed: Step 'Plan' failed: Harness error: HTTP request failed: error sending request for url (http://10.200.0.3:8500/v1/responses)

This error message is lacking details — there is no indication of why the request failed (timeout, connection refused, DNS error, etc.) and no status code.

Root cause

HarnessError::Http used #[from] reqwest::Error, which delegates to reqwest::Error's default Display impl. That impl only produces error sending request for url (...) and does not include the underlying cause (timeout, connection refused, DNS failure) or a status code if one was received.

Additionally, when response.text().await? failed on the body read, the already-captured HTTP status code was silently lost.

Changes

src/harness.rs

  1. Replaced HarnessError::Http(#[from] reqwest::Error) with a structured variant:

    Http {
        message: String,
    }
  2. Added HarnessError::from_reqwest_error(err, url) — a helper that builds a descriptive Http error by:

    • Surfacing timeout status (is_timeout()) as timeout reached
    • Surfacing connect-failure status (is_connect()) as connection failed
    • Including the HTTP status code if one was received (err.status())
    • Walking the full std::error::Error::source() cause chain to get the real root cause (e.g. dns error: failed to lookup address information, Connection refused (os error 111))
  3. Updated execute_step_with_error_path to use .map_err(|e| HarnessError::from_reqwest_error(e, &url))? instead of the bare ? operator on both the request send and the body read, so both failure paths produce a structured, descriptive error.

Before (issue #225):

HTTP request failed: error sending request for url (http://10.200.0.3:8500/v1/responses)

After (timeout example):

HTTP request failed: error sending request for url (http://10.200.0.3:8500/v1/responses): timeout reached: operation timed out

After (connection refused example):

HTTP request failed: error sending request for url (http://localhost:8500/v1/responses): connection failed: Connection refused (os error 111)

After (DNS failure example):

HTTP request failed: error sending request for url (http://nonexistent.invalid:8500/v1/responses): connection failed: dns error: failed to lookup address information: nonexistent.invalid

Test plan

  • cargo build — compiles cleanly
  • cargo test — all 120+ tests pass (lib + integration)
  • cargo clippy --lib -- -W clippy::all — no warnings
  • New unit tests for the structured HarnessError::Http variant:
    • test_harness_error_http_includes_url — verifies URL, timeout indicator, and cause chain appear in the display
    • test_harness_error_http_connection_refused — verifies connection-failure indicator and cause
    • test_harness_error_http_minimal — verifies the message is still meaningful with no extra details
  • New integration test test_harness_http_error_includes_details (regression test for issue Improve agent request error handling #225)

Replace the opaque HarnessError::Http(#[from] reqwest::Error) variant
with a structured variant that captures the URL, timeout/connect
status, and full cause chain. The previous error message was just
'HTTP request failed: error sending request for url (...)' with no
indication of *why* the request failed.

The new from_reqwest_error() helper walks the reqwest::Error source
chain to surface the root cause (DNS failure, connection refused,
timeout, etc.) and includes timeout/connect indicators.

Closes mintybasil#225
@mintybasil
mintybasil merged commit 3dd0e96 into mintybasil:main Jun 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve agent request error handling

2 participants