From b125630a86739d443eb85513456726fb1a4cc687 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Thu, 2 Jul 2026 00:27:43 +1000 Subject: [PATCH] fix: detect UpstreamError with errors.As in isNetworkError The stale-on-error path used a bare type assertion, which fails if the UpstreamError is ever wrapped. Use errors.As so wrapping is handled. Refs #68 --- internal/proxy/engine.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/proxy/engine.go b/internal/proxy/engine.go index ba63e78..3c5530c 100644 --- a/internal/proxy/engine.go +++ b/internal/proxy/engine.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "io" "log/slog" @@ -431,8 +432,6 @@ func (e *UpstreamError) Error() string { return fmt.Sprintf("upstream error: %v" func (e *UpstreamError) Unwrap() error { return e.Err } func isNetworkError(err error) bool { - if _, ok := err.(*UpstreamError); ok { - return true - } - return false + var ue *UpstreamError + return errors.As(err, &ue) }