From 0b8d1c0a78ba55810398e0abaeb33a53200215c5 Mon Sep 17 00:00:00 2001 From: "Guan-Ming (Wesley) Chiu" <105915352+guan404ming@users.noreply.github.com> Date: Sat, 18 Jul 2026 16:34:24 +0800 Subject: [PATCH] Reject unsupported require_approval in LLM branch and schema compare operators --- .../airflow/providers/common/ai/operators/llm_branch.py | 2 ++ .../providers/common/ai/operators/llm_schema_compare.py | 2 ++ .../ai/tests/unit/common/ai/operators/test_llm_branch.py | 9 +++++++++ .../unit/common/ai/operators/test_llm_schema_compare.py | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/providers/common/ai/src/airflow/providers/common/ai/operators/llm_branch.py b/providers/common/ai/src/airflow/providers/common/ai/operators/llm_branch.py index 0395040852f53..b6a25a7811eb0 100644 --- a/providers/common/ai/src/airflow/providers/common/ai/operators/llm_branch.py +++ b/providers/common/ai/src/airflow/providers/common/ai/operators/llm_branch.py @@ -60,6 +60,8 @@ def __init__( **kwargs: Any, ) -> None: kwargs.pop("output_type", None) + if kwargs.get("require_approval"): + raise ValueError("require_approval=True is not supported by LLMBranchOperator.") super().__init__(**kwargs) self.allow_multiple_branches = allow_multiple_branches diff --git a/providers/common/ai/src/airflow/providers/common/ai/operators/llm_schema_compare.py b/providers/common/ai/src/airflow/providers/common/ai/operators/llm_schema_compare.py index b51ea7c1f7c3b..d65ca521876b8 100644 --- a/providers/common/ai/src/airflow/providers/common/ai/operators/llm_schema_compare.py +++ b/providers/common/ai/src/airflow/providers/common/ai/operators/llm_schema_compare.py @@ -127,6 +127,8 @@ def __init__( **kwargs: Any, ) -> None: kwargs.pop("output_type", None) + if kwargs.get("require_approval"): + raise ValueError("require_approval=True is not supported by LLMSchemaCompareOperator.") super().__init__(**kwargs) self.data_sources = data_sources or [] self.db_conn_ids = db_conn_ids or [] diff --git a/providers/common/ai/tests/unit/common/ai/operators/test_llm_branch.py b/providers/common/ai/tests/unit/common/ai/operators/test_llm_branch.py index 390137e9fc9be..fccf5e2f83737 100644 --- a/providers/common/ai/tests/unit/common/ai/operators/test_llm_branch.py +++ b/providers/common/ai/tests/unit/common/ai/operators/test_llm_branch.py @@ -54,6 +54,15 @@ def test_output_type_ignored(self): # the real output_type is built dynamically from downstream_task_ids assert op.output_type is str + def test_require_approval_rejected(self): + with pytest.raises(ValueError, match="require_approval=True is not supported"): + LLMBranchOperator( + task_id="test", + prompt="pick a branch", + llm_conn_id="my_llm", + require_approval=True, + ) + @patch.object(LLMBranchOperator, "do_branch") @patch("airflow.providers.common.ai.operators.llm.PydanticAIHook", autospec=True) def test_execute_single_branch(self, mock_hook_cls, mock_do_branch): diff --git a/providers/common/ai/tests/unit/common/ai/operators/test_llm_schema_compare.py b/providers/common/ai/tests/unit/common/ai/operators/test_llm_schema_compare.py index c7a23de583847..01fee1950d130 100644 --- a/providers/common/ai/tests/unit/common/ai/operators/test_llm_schema_compare.py +++ b/providers/common/ai/tests/unit/common/ai/operators/test_llm_schema_compare.py @@ -97,6 +97,11 @@ class TestLLMSchemaCompareOperator: "at-least two combinations", id="one_datasource_only", ), + pytest.param( + {"require_approval": True}, + "require_approval=True is not supported", + id="require_approval", + ), ], ) def test_init_validation(self, kwargs, expected_error):