Return better errors for unavailable error codes#2336
Merged
Conversation
If we can determine that the error from login is due to a connect unavailable error, we should return more details to aid in troubleshooting. Update wrapError to return a better error message in case of a TLS certificate error (could be a MITM attack or an untrusted certificate).
Member
Author
|
When testing locally, the behavior is: Before: After: |
unmultimedio
reviewed
Aug 2, 2023
Comment on lines
+191
to
196
| if connectErr := new(connect.Error); errors.As(err, &connectErr) && connectErr.Code() == connect.CodeUnavailable { | ||
| return connectErr | ||
| } | ||
| // We don't want to use the default error from wrapError here if the error | ||
| // an unauthenticated error. | ||
| return errors.New("invalid token provided") |
Member
There was a problem hiding this comment.
I thought you were going to invoke wrapError here.
bufdev
reviewed
Aug 2, 2023
| "strings" | ||
| ) | ||
|
|
||
| // wrappedTLSError returns an unwrapped TLS error or nil if the error is another type of error. |
Member
There was a problem hiding this comment.
I'd like to see a bit more documentation here as to the motivation for this, so that in the future we understand why this is here in case we need to debug
Member
Author
There was a problem hiding this comment.
Ok - this is just a temporary thing until Go 1.21 is released and we can remove and just use errors.As which will be a lot more readable. I'll update to add more details though.
bufdev
approved these changes
Aug 2, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If we can determine that the error from login is due to a connect unavailable error, we should return more details to aid in troubleshooting. Update wrapError to return a better error message in case of a TLS certificate error (could be a MITM attack or an untrusted certificate).