From 1bed1ad376347f981fa62458ad979c9c526fcb81 Mon Sep 17 00:00:00 2001 From: rosstimothy <39066650+rosstimothy@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:27:05 -0500 Subject: [PATCH] Prevent panicing if license expiry is not populated (#49844) Panic was caught by a customer running 16.4.9 http: panic serving [2a13:5947:111:20::1c86:2e30]:49995: runtime error: invalid memory address or nil pointer dereference goroutine 597943 [running]: net/http.(*conn).serve.func1() net/http/server.go:1903 +0xbe panic({0x556eb28d1e60?, 0x556eb95ef2d0?}) runtime/panic.go:770 +0x132 github.com/gravitational/teleport/lib/web.(*Handler).getUserContext(0xc002599408, {0xc002599408?, 0xc00bb18b40?}, 0xc00f4859e0, {0x1?, 0x1?, 0xc00bb18b40?}, 0xc00bb18b40, {0x556eb3eeb8f8, 0xc001af2f20}) github.com/gravitational/teleport/lib/web/apiserver.go:1230 +0x6ef github.com/gravitational/teleport/lib/web.(*Handler).bindDefaultEndpoints.(*Handler).WithClusterAuth.func50({0x556eb3ea4940, 0xc00d6158c0}, 0xc00f4859e0, {0xc00d615920, 0x1, 0x3}) --- lib/web/apiserver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/apiserver.go b/lib/web/apiserver.go index dc9348c4f410d..d674d094248c8 100644 --- a/lib/web/apiserver.go +++ b/lib/web/apiserver.go @@ -1242,7 +1242,7 @@ func (h *Handler) getUserContext(w http.ResponseWriter, r *http.Request, p httpr if err != nil { return nil, trace.Wrap(err) } - if !pingResp.LicenseExpiry.IsZero() { + if pingResp.LicenseExpiry != nil && !pingResp.LicenseExpiry.IsZero() { userContext.Cluster.LicenseExpiry = pingResp.LicenseExpiry }