Skip to content

Commit 4c20d77

Browse files
committed
return a wrapped error
1 parent 701bd46 commit 4c20d77

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

internal/integration/client_side_encryption_prose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3111,7 +3111,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
31113111

31123112
ceo := options.ClientEncryption().
31133113
SetKeyVaultNamespace(kvNamespace).
3114-
SetKmsProviders(fullKmsProvidersMap).
3114+
SetKmsProviders(kmsProviders).
31153115
SetTLSConfig(map[string]*tls.Config{dataKey.provider: tlsCfg})
31163116
clientEncryption, err := mongo.NewClientEncryption(keyVaultClient, ceo)
31173117
require.NoError(mt, err, "error on NewClientEncryption: %v", err)

x/mongo/driver/crypt.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,7 @@ func (c *crypt) decryptKey(kmsCtx *mongocrypt.KmsContext) error {
398398
res := make([]byte, bytesNeeded)
399399
bytesRead, err := conn.Read(res)
400400
if err != nil {
401-
if kmsCtx.Fail() {
402-
err = nil
403-
}
404-
return err
401+
return kmsCtx.RequestError()
405402
}
406403

407404
if err = kmsCtx.FeedResponse(res[:bytesRead]); err != nil {

x/mongo/driver/mongocrypt/mongocrypt_kms_context.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ func (kc *KmsContext) createErrorFromStatus() error {
7878
return errorFromStatus(status)
7979
}
8080

81-
// Fail returns a boolean indicating whether the failed request may be retried.
82-
func (kc *KmsContext) Fail() bool {
83-
return bool(C.mongocrypt_kms_ctx_fail(kc.wrapped))
81+
// RequestError returns the source of the network error for KMS requests.
82+
func (kc *KmsContext) RequestError() error {
83+
if bool(C.mongocrypt_kms_ctx_fail(kc.wrapped)) {
84+
return nil
85+
}
86+
return kc.createErrorFromStatus()
8487
}

x/mongo/driver/mongocrypt/mongocrypt_kms_context_not_enabled.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (kc *KmsContext) FeedResponse([]byte) error {
3838
panic(cseNotSupportedMsg)
3939
}
4040

41-
// Fail returns a boolean indicating whether the failed request may be retried.
42-
func (kc *KmsContext) Fail() bool {
41+
// RequestError returns the source of the network error for KMS requests.
42+
func (kc *KmsContext) RequestError() error {
4343
panic(cseNotSupportedMsg)
4444
}

0 commit comments

Comments
 (0)