From 465ebff9afe0bbe2469baec869aa91ec197ef785 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Thu, 13 Jun 2024 10:30:36 +0200 Subject: [PATCH] fix: check if expiration date is nil before logging --- pkg/cmd/sessions/set/set.manual.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/sessions/set/set.manual.go b/pkg/cmd/sessions/set/set.manual.go index 26976a509..15445da79 100644 --- a/pkg/cmd/sessions/set/set.manual.go +++ b/pkg/cmd/sessions/set/set.manual.go @@ -161,11 +161,15 @@ func (n *CmdSet) RunE(cmd *cobra.Command, args []string) error { shouldBeValidFor := cfg.TokenValidFor() expiresSoon, expiresAt := ShouldRenewToken(tok, shouldBeValidFor) - if expiresSoon { - log.Warnf("Ignoring existing token as it will expire soon. minimumValidFor=%s, tokenExpiresAt=%s", shouldBeValidFor, expiresAt.Format(time.RFC3339)) - client.SetToken("") - } else if expiresAt != nil { - log.Infof("Token expiresAt: %s", expiresAt.Format(time.RFC3339)) + if expiresAt != nil { + if expiresSoon { + log.Warnf("Ignoring existing token as it will expire soon. minimumValidFor=%s, tokenExpiresAt=%s", shouldBeValidFor, expiresAt.Format(time.RFC3339)) + client.SetToken("") + } else { + log.Infof("Token expiresAt: %s", expiresAt.Format(time.RFC3339)) + } + } else { + log.Infof("Ignoring invalid token") } } }