From 660cb3333fe69f396610190d6ac54130f0aa11a7 Mon Sep 17 00:00:00 2001 From: Ashley <73482956+ascopes@users.noreply.github.com> Date: Thu, 19 Jun 2025 10:46:58 +0100 Subject: [PATCH] GH-676: Fix nil pointer panic when setting an HTTP proxy Addresses a logic error in internal/apiclient/httpclient.go that would only attempt to construct an `ApigeeAPIClient` with an HTTP proxy if the previous operation that attempts to parse the proxy URL failed. This bug results in the API client singleton never being created when the proxy URL is valid, and the singleton is only created if the proxy is unset or has an invalid value. When using a proxy, this issue bubbles up and results in a nil-pointer dereference on the global API client singleton, which crashes the runtime. Inverting the condition addresses this issue. Fixes GH-676. --- internal/apiclient/httpclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/apiclient/httpclient.go b/internal/apiclient/httpclient.go index 685ac9362..97d6b68c3 100644 --- a/internal/apiclient/httpclient.go +++ b/internal/apiclient/httpclient.go @@ -395,7 +395,7 @@ func GetHttpClient() (err error) { } if GetProxyURL() != "" { - if proxyUrl, err := url.Parse(GetProxyURL()); err != nil { + if proxyUrl, err := url.Parse(GetProxyURL()); err == nil { ApigeeAPIClient = &RateLimitedHTTPClient{ client: &http.Client{ Transport: &http.Transport{