From d795e6139629ce2664159387a1a56eb03243fbb4 Mon Sep 17 00:00:00 2001 From: Hector Castejon Diaz Date: Mon, 9 Mar 2026 07:53:27 +0000 Subject: [PATCH 1/2] Fix debug logs showing empty Host for API requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API requests use relative paths, so http.NewRequestWithContext leaves r.Host empty. Go copies r.URL.Host into the Host header automatically before sending, so requests reach the correct server — but debug logs read r.Host directly and showed an empty host. Set r.Host explicitly in the visitor alongside r.URL.Host. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Hector Castejon Diaz --- NEXT_CHANGELOG.md | 2 ++ config/api_client.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 274315be8..001b88fb7 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,6 +8,8 @@ ### Bug Fixes + - Fix debug logs showing empty `Host` for API requests. + ### Documentation ### Internal Changes diff --git a/config/api_client.go b/config/api_client.go index d5d54b985..aceb465c5 100644 --- a/config/api_client.go +++ b/config/api_client.go @@ -36,8 +36,15 @@ func HTTPClientConfigFromConfig(cfg *Config) (httpclient.ClientConfig, error) { if err != nil { return err } + // API requests are made with relative paths (e.g. /api/2.0/...). + // r.URL.Host and r.URL.Scheme direct the HTTP client to the right + // server. r.Host sets the Host header explicitly; if r.Host is + // empty, Go copies r.URL.Host into the Host header automatically + // before sending, so both reach the same server — but leaving + // r.Host empty makes debug logs misleadingly show an empty host. r.URL.Host = url.Host r.URL.Scheme = url.Scheme + r.Host = url.Host return nil }, authInUserAgentVisitor(cfg), From f80d2af0c009cc85c082d8c92f6d0980dbb60833 Mon Sep 17 00:00:00 2001 From: Hector Castejon Diaz Date: Mon, 9 Mar 2026 08:12:44 +0000 Subject: [PATCH 2/2] Only set r.Host when not already set Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Hector Castejon Diaz --- config/api_client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/api_client.go b/config/api_client.go index aceb465c5..12ab02f32 100644 --- a/config/api_client.go +++ b/config/api_client.go @@ -44,7 +44,9 @@ func HTTPClientConfigFromConfig(cfg *Config) (httpclient.ClientConfig, error) { // r.Host empty makes debug logs misleadingly show an empty host. r.URL.Host = url.Host r.URL.Scheme = url.Scheme - r.Host = url.Host + if r.Host == "" { + r.Host = url.Host + } return nil }, authInUserAgentVisitor(cfg),