From 9979b9d082b3c432c3d63998588a2d698d489ea5 Mon Sep 17 00:00:00 2001 From: rkonfj Date: Wed, 3 Jan 2024 20:25:42 +0800 Subject: [PATCH] oauthutil: avoid panic when `*token` and `*ts.token` are the same the field `raw` of `oauth2.Token` may be an uncomparable type(often map[string]interface{}), causing `*token != *ts.token` expression to panic(comparing uncomparable type ...). the semantics of comparing whether two tokens are the same can be achieved by comparing accessToken, refreshToken and expire to avoid panic. --- lib/oauthutil/oauthutil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oauthutil/oauthutil.go b/lib/oauthutil/oauthutil.go index d3562e41a..7b0fb9d9d 100644 --- a/lib/oauthutil/oauthutil.go +++ b/lib/oauthutil/oauthutil.go @@ -292,7 +292,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) { if err != nil { return nil, fmt.Errorf("couldn't fetch token: %w", err) } - changed = changed || (*token != *ts.token) + changed = changed || token.AccessToken != ts.token.AccessToken || token.RefreshToken != ts.token.RefreshToken || token.Expiry != ts.token.Expiry ts.token = token if changed { // Bump on the expiry timer if it is set