Skip to content

Commit 7b62a50

Browse files
authored
fix(cli): return consistent authentication error (#2450)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent e034361 commit 7b62a50

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/cli/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ func errorInfo(err error, logger zerolog.Logger) (string, int) {
106106
return msg, exitCode
107107
}
108108

109-
func isWrappedErr(grpcStatus *status.Status, err *errors.Error) bool {
110-
target := errors.FromError(grpcStatus.Err())
109+
// target is the expected error
110+
// grpcStatus is the actual error that might be wrapped in both the status and the error
111+
func isWrappedErr(grpcStatus *status.Status, target *errors.Error) bool {
112+
err := errors.FromError(grpcStatus.Err())
113+
// The error might be wrapped since the CLI sometimes returns a wrapped error
114+
if errors.Is(err, target) {
115+
return true
116+
}
117+
111118
return target.Code == err.Code && err.Message == target.Message
112119
}

0 commit comments

Comments
 (0)