Preserve caller cancellation in HTTP smoke probes

This commit is contained in:
2026-10-13 20:22:06 +00:00
parent 972a103a97
commit 208ff42915
4 changed files with 104 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ package usecase
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
@@ -58,7 +59,7 @@ func (p reachabilityProbe) run(
result.reachable = boolPointer(false)
}
if requestErr != nil {
result.failure = generation.ClassifyFailure(fmt.Errorf("%w: %w", llm.ErrTransport, requestErr))
result.failure = httpProbeFailure(ctx, requestErr)
if !evidence.DispatchInvoked {
return result, fmt.Errorf("execute reachability request: %w", requestErr)
}
@@ -66,6 +67,15 @@ func (p reachabilityProbe) run(
return result, nil
}
// Failed I/O can lose context error identity. Check the caller at that boundary,
// without reclassifying a probe that already established its result.
func httpProbeFailure(ctx context.Context, err error) domain.ExecutionFailureKind {
if contextErr := ctx.Err(); contextErr != nil {
return generation.ClassifyFailure(contextErr)
}
return generation.ClassifyFailure(errors.Join(llm.ErrTransport, err))
}
func endpointWithoutUserInfo(endpoint string) (string, error) {
parsed, err := url.Parse(endpoint)
if err != nil {