You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2025/10/14 15:05:52 UTC

(beam) 01/01: Handle null keys in gbek

This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a commit to branch users/damccorm/nullKeys
in repository https://gitbox.apache.org/repos/asf/beam.git

commit e6911317f4ee4040c334320ecdb777545f20d1e7
Author: Danny McCormick <da...@google.com>
AuthorDate: Tue Oct 14 11:05:45 2025 -0400

    Handle null keys in gbek
---
 .../main/java/org/apache/beam/sdk/transforms/GroupByEncryptedKey.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupByEncryptedKey.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupByEncryptedKey.java
index 1f4b7535d89..6a9f0cb78a9 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupByEncryptedKey.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupByEncryptedKey.java
@@ -251,7 +251,8 @@ public class GroupByEncryptedKey<K, V>
         byte[] decryptedKeyBytes = this.cipher.doFinal(encryptedKey);
         K key = decode(this.keyCoder, decryptedKeyBytes);
 
-        if (key != null) {
+        // If somehow the key was decoded to null, but the byte string is non-empty, throw.
+        if (key != null || decryptedKeyBytes == null || decryptedKeyBytes.length == 0) {
           if (!decryptedKvs.containsKey(key)) {
             decryptedKvs.put(key, new java.util.ArrayList<>());
           }