fix: exclude db connection error details (#7785)

* fix: exclude db connection error details

* remove potential recursive error
This commit is contained in:
Livio Spring
2024-04-23 10:35:25 +02:00
committed by GitHub
parent 42bd636d21
commit cc0c06f225
4 changed files with 35 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package gerrors
import (
"errors"
"github.com/jackc/pgx/v5/pgconn"
"github.com/zitadel/logging"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -35,6 +36,10 @@ func ExtractZITADELError(err error) (c codes.Code, msg, id string, ok bool) {
if err == nil {
return codes.OK, "", "", false
}
connErr := new(pgconn.ConnectError)
if ok := errors.As(err, &connErr); ok {
return codes.Internal, "db connection error", "", true
}
zitadelErr := new(zerrors.ZitadelError)
if ok := errors.As(err, &zitadelErr); !ok {
return codes.Unknown, err.Error(), "", false