Preserve caller cancellation in HTTP smoke probes
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user