atc0005 / check-mail

Various tools used to monitor mail services
MIT License
9 stars 0 forks source link

Repeat error message prefix when token retrieval failure occurs #815

Closed atc0005 closed 1 day ago

atc0005 commented 1 day ago

Someone reported a failure for the list-emails binary today and shared an error message snippet.

The first line only:

failed to retrieve token: failed to retrieve token: oauth2: cannot fetch token: 401 Unauthorized

The error message should instead be (at a minimum reduced to):

-failed to retrieve token: failed to retrieve token: oauth2: cannot fetch token: 401 Unauthorized
+failed to retrieve token: oauth2: cannot fetch token: 401 Unauthorized

Further tweaks could be applied to further refine the message, but we can at least not repeat the prefix.


Note: The error is occurring because the associated secret has expired and needs to be regenerated.

The detailed error message (not shown here) offers guidance and also specifies the app ID to help the user locate the Azure App entry to generate a new secret.

atc0005 commented 1 day ago

Focus here:

https://github.com/atc0005/check-mail/blob/da496ce9eb6ebe79c7bcba3219d7f8c2f3830ff6/internal/oauth2/oauth2.go#L63-L66

and here:

https://github.com/atc0005/check-mail/blob/da496ce9eb6ebe79c7bcba3219d7f8c2f3830ff6/internal/mbxs/auth.go#L136-L139