From 7b5b9f5ce2f28a1aa2598028dad2ae894c7699b9 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 6 Apr 2026 01:45:54 +0000 Subject: [PATCH] client/web: fix nil metricCapture crash in mockLocalAPI The upload-client-metrics handler called metricCapture without checking if it was nil or if the metrics slice was empty. Most tests pass nil for metricCapture, so if a metrics upload races in during the test, it panics. Fixes #19252 Change-Id: Ib904d1fe6779067dc2a153d1680b8f50cba9c773 Signed-off-by: Brad Fitzpatrick --- client/web/web_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/web/web_test.go b/client/web/web_test.go index 876e526ab..032cd5222 100644 --- a/client/web/web_test.go +++ b/client/web/web_test.go @@ -1477,7 +1477,9 @@ func mockLocalAPI(t *testing.T, whoIs map[string]*apitype.WhoIsResponse, self fu http.Error(w, "invalid JSON body", http.StatusBadRequest) return } - metricCapture(metricNames[0].Name) + if metricCapture != nil && len(metricNames) > 0 { + metricCapture(metricNames[0].Name) + } writeJSON(w, struct{}{}) return case "/localapi/v0/logout":