From 2bd8c347d083fbd165ff57ea53253803c05ed5f7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 8 Mar 2026 03:17:52 +0000 Subject: [PATCH] fix(auth): preserve extra scopes replay and satisfy lint on current main (#421) (thanks @peteradams2026) --- internal/cmd/gmail_watch_cmds.go | 7 ++++--- internal/googleauth/service.go | 1 + internal/googleauth/service_test.go | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/cmd/gmail_watch_cmds.go b/internal/cmd/gmail_watch_cmds.go index 625ebe3..0220d5d 100644 --- a/internal/cmd/gmail_watch_cmds.go +++ b/internal/cmd/gmail_watch_cmds.go @@ -427,11 +427,12 @@ func writeWatchState(ctx context.Context, state gmailWatchState, showSecrets boo u.Out().Printf("hook_max_bytes\t%d", state.Hook.MaxBytes) } if state.Hook.Token != "" { - if showSecrets { + switch { + case showSecrets: u.Out().Printf("hook_token\t%s", state.Hook.Token) - } else if len(state.Hook.Token) > 4 { + case len(state.Hook.Token) > 4: u.Out().Printf("hook_token\t%s...(%d chars)", state.Hook.Token[:4], len(state.Hook.Token)) - } else { + default: u.Out().Printf("hook_token\t[REDACTED]") } } diff --git a/internal/googleauth/service.go b/internal/googleauth/service.go index 77b26db..63bae6a 100644 --- a/internal/googleauth/service.go +++ b/internal/googleauth/service.go @@ -391,6 +391,7 @@ func ScopesForManageWithOptions(services []Service, opts ScopeOptions) ([]string if len(opts.ExtraScopes) > 0 { merged = mergeScopes(merged, opts.ExtraScopes) } + return merged, nil } diff --git a/internal/googleauth/service_test.go b/internal/googleauth/service_test.go index 68aae02..a1a10bc 100644 --- a/internal/googleauth/service_test.go +++ b/internal/googleauth/service_test.go @@ -519,6 +519,7 @@ func TestScopesForManageWithOptions_ExtraScopes(t *testing.T) { // De-duplication: gmail.readonly should appear exactly once count := 0 + for _, s := range scopes { if s == "https://www.googleapis.com/auth/gmail.readonly" { count++