From a0f93ca7c0162e43f18dc041ad4513ac79120141 Mon Sep 17 00:00:00 2001 From: sec-check Date: Thu, 27 Aug 2026 02:11:31 -0400 Subject: [PATCH] [quality] fix nil-logger panic in TestHandleRepoActivityReportsPhaseOneHonesty TestHandleRepoActivityReportsPhaseOneHonesty constructed the dashboard server with NewServer(0, nil). Server.RegisterAPI wires the contribute routes, and NewContributeWSHub -> loadCompletedTasks logs unconditionally via h.logger.Info, so the nil logger crashed the whole pkg/dashboard test binary with a SIGSEGV on every 'go test ./...' run. Pass an io.Discard slog logger, matching every other dashboard test (e.g. advisory_state_test.go, api_contribute_handler_branches_test.go). Test-only change; no production code touched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check --- src/pkg/dashboard/activity_collector_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pkg/dashboard/activity_collector_test.go b/src/pkg/dashboard/activity_collector_test.go index 8a80bd6d3..ae50171c3 100644 --- a/src/pkg/dashboard/activity_collector_test.go +++ b/src/pkg/dashboard/activity_collector_test.go @@ -4,6 +4,8 @@ import ( "compress/gzip" "context" "encoding/json" + "io" + "log/slog" "net/http" "net/http/httptest" "os" @@ -218,7 +220,9 @@ func TestHandleRepoActivityReportsPhaseOneHonesty(t *testing.T) { ac.nowFn = func() time.Time { return now } ac.collect() - s := NewServer(0, nil) + // RegisterAPI wires ContributeWSHub, which logs unconditionally; a nil + // logger panics in NewContributeWSHub → loadCompletedTasks. + s := NewServer(0, slog.New(slog.NewTextHandler(io.Discard, nil))) s.RegisterAPI(&Dependencies{Activity: ac}) rec := httptest.NewRecorder() req := httptest.NewRequest(http.MethodGet, "/api/repo-activity", nil)