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

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-8240-707849a00fe581c02f3cc8c2c038e8f4e773403b
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 154042ae219f20e8bdf54a5f2312f988cc80e627
Author: carloea2 <[email protected]>
AuthorDate: Thu Oct 15 22:28:57 2026 +0000

    feat(pyamber): reject invalid port booleans (#8240)
    
    ### What changes were proposed in this PR?
    
    The Python GlobalPortIdentity decoder now rejects invalid boolean tokens
    instead of silently treating them as false. Valid mixed-case true and
    false values remain supported.
    
    ### Any related issues, documentation, discussions?
    
    Closes #8239
    
    ### How was this PR tested?
    
    Retested with Python 3.12 on Windows in a fresh detached worktree from
    upstream main at `7426431337`, which includes the merged loop-completion
    change #8938. Regression before implementation: 2 failed, 48 passed.
    After implementation: 50 passed.
    
    Generate protobufs with `bash bin/python-proto-gen.sh`, then run from
    `amber`:
    
    ```text
    python -m pytest src/test/python/core/util/test_virtual_identity.py 
src/test/python/core/storage/test_vfs_uri_factory.py -q --tb=line -p 
no:cacheprovider
    python -m ruff check src/main/python src/test/python
    python -m ruff format --check src/main/python src/test/python
    ```
    
    Ruff lint and formatting pass for all 217 Python files.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Codex
---
 amber/src/main/python/core/util/virtual_identity.py      |  6 ++++++
 amber/src/test/python/core/util/test_virtual_identity.py | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/amber/src/main/python/core/util/virtual_identity.py 
b/amber/src/main/python/core/util/virtual_identity.py
index 0a9de0ccc4..804d9d918c 100644
--- a/amber/src/main/python/core/util/virtual_identity.py
+++ b/amber/src/main/python/core/util/virtual_identity.py
@@ -111,6 +111,12 @@ def deserialize_global_port_identity(encoded_str: str) -> 
GlobalPortIdentity:
     port_id = int(port_id_str)
     if port_id < 0:
         raise ValueError(f"portId must be non-negative: {port_id}")
+    for field, value in (("isInternal", is_internal_str), ("isInput", 
is_input_str)):
+        if value.lower() not in ("true", "false"):
+            raise ValueError(
+                f"Invalid {field}: {value}. Expected true/false in 
GlobalPortIdentity "
+                f"encoding: {encoded_str}"
+            )
     is_internal = is_internal_str.lower() == "true"
     is_input_port = is_input_str.lower() == "true"
     op_id = PhysicalOpIdentity(
diff --git a/amber/src/test/python/core/util/test_virtual_identity.py 
b/amber/src/test/python/core/util/test_virtual_identity.py
index ad60391c28..fae65b4e6d 100644
--- a/amber/src/test/python/core/util/test_virtual_identity.py
+++ b/amber/src/test/python/core/util/test_virtual_identity.py
@@ -195,6 +195,16 @@ class TestDeserializeGlobalPortIdentity:
         assert result.port_id.internal is True
         assert result.input is False
 
+    @pytest.mark.parametrize(
+        ("field", "valid"), [("isInternal", "false"), ("isInput", "true")]
+    )
+    def test_rejects_invalid_boolean_value(self, field, valid):
+        encoded = (
+            
"(logicalOpId=op,layerName=l,portId=0,isInternal=false,isInput=true)"
+        ).replace(f"{field}={valid}", f"{field}=maybe")
+        with pytest.raises(ValueError, match=f"Invalid {field}"):
+            deserialize_global_port_identity(encoded)
+
     def test_raises_value_error_on_malformed_input(self):
         with pytest.raises(ValueError, match="Invalid GlobalPortIdentity 
format"):
             deserialize_global_port_identity("not-a-port-id")

Reply via email to