From 46abc04d52a755cc5506aa3f84066519b30aac30 Mon Sep 17 00:00:00 2001 From: Mihir Dixit Date: Fri, 17 Apr 2026 20:41:58 +0000 Subject: [PATCH] shared/utils: add timeout to HTTP client in GetURLBody The existing GetURLBody function used the package-level http.Get which has no timeout configured. If a remote server hangs or is slow to respond, the download would block indefinitely with no way to recover short of killing the process. Switched to a local http.Client with a one-minute timeout, which is the same value already used by the API client in shared/api/api.go. Signed-off-by: Mihir Dixit --- shared/utils/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/utils/utils.go b/shared/utils/utils.go index ab9199a3b11..45994aa4c1a 100644 --- a/shared/utils/utils.go +++ b/shared/utils/utils.go @@ -22,6 +22,7 @@ import ( "strconv" "strings" "syscall" + "time" "unicode" "github.com/rs/zerolog" @@ -301,7 +302,8 @@ func ContainsUpperCase(str string) bool { func GetURLBody(URL string) ([]byte, error) { // Download the key from the URL log.Debug().Msgf("Downloading %s", URL) - resp, err := http.Get(URL) + client := &http.Client{Timeout: time.Minute} + resp, err := client.Get(URL) if err != nil { return nil, Errorf(err, L("error downloading from %s"), URL) }