From 43f75085e79afc85d17fce29e9cf9453db7154fb Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Wed, 16 Sep 2026 23:05:28 +0300 Subject: [PATCH] fix(telemetry): the opt-out beacon tolerates a Service without an HTTP client NotifyConfigChanged fires the opt-out beacon from a goroutine; several telemetry tests build the Service as a bare literal with no client, so under an unlucky shuffle order the goroutine reached http.Client.Do on a nil receiver and took the whole test binary down (Unit Tests (shuffle) on #1285, seed 1789588229734730758). Refuse to send instead. Co-Authored-By: Claude Opus 5 --- internal/telemetry/optout.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/telemetry/optout.go b/internal/telemetry/optout.go index aa5cf011d..5a2cf8dfc 100644 --- a/internal/telemetry/optout.go +++ b/internal/telemetry/optout.go @@ -132,6 +132,12 @@ func (s *Service) SendOptOutBeacon(ctx context.Context) error { } req.Header.Set("Content-Type", "application/json") + // The beacon is fire-and-forget from NotifyConfigChanged, so a Service + // built without a client (test literals do this) must not take the + // goroutine — and the test binary — down with a nil dereference. + if s.client == nil { + return errors.New("send opt-out beacon: no HTTP client configured") + } resp, err := s.client.Do(req) if err != nil { return fmt.Errorf("send opt-out beacon: %w", err)