Skip to content

Commit dc96bec

Browse files
committed
fine tune error message
1 parent a99e830 commit dc96bec

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

modules/secret/secret.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func DecryptSecret(key, cipherHex string) (string, error) {
7373
}
7474
plaintext, err := AesDecrypt(keyHash[:], ciphertext)
7575
if err != nil {
76-
return "", fmt.Errorf("failed to decrypt by secret, secret key (SECRET_KEY) might be incorrect: %w", err)
76+
return "", fmt.Errorf("failed to decrypt by secret, the key (maybe SECRET_KEY?) might be incorrect: %w", err)
7777
}
7878
return string(plaintext), nil
7979
}

modules/secret/secret_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func TestEncryptDecrypt(t *testing.T) {
2424
assert.ErrorContains(t, err, "invalid hex string")
2525

2626
_, err = DecryptSecret("a", "bb")
27-
assert.ErrorContains(t, err, "secret key (SECRET_KEY) might be incorrect: AesDecrypt ciphertext too short")
27+
assert.ErrorContains(t, err, "the key (maybe SECRET_KEY?) might be incorrect: AesDecrypt ciphertext too short")
2828

2929
_, err = DecryptSecret("a", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
30-
assert.ErrorContains(t, err, "secret key (SECRET_KEY) might be incorrect: AesDecrypt invalid decrtyped base64 string")
30+
assert.ErrorContains(t, err, "the key (maybe SECRET_KEY?) might be incorrect: AesDecrypt invalid decrypted base64 string")
3131
}

0 commit comments

Comments
 (0)