This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v3-1-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 084744283790d8f0595130fbf1a84e51496e228b Author: Wei Lee <[email protected]> AuthorDate: Thu Sep 18 06:51:40 2025 +0800 fix(hitl): fix HITL timeout error handling (#55760) (cherry picked from commit 3ee8cd436feabaa8eff1931650a755ef53f3dfb9) --- .../airflow/providers/standard/operators/hitl.py | 2 +- .../tests/unit/standard/operators/test_hitl.py | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/providers/standard/src/airflow/providers/standard/operators/hitl.py b/providers/standard/src/airflow/providers/standard/operators/hitl.py index 1c5559adf00..f40abe1e467 100644 --- a/providers/standard/src/airflow/providers/standard/operators/hitl.py +++ b/providers/standard/src/airflow/providers/standard/operators/hitl.py @@ -184,7 +184,7 @@ class HITLOperator(BaseOperator): ) def process_trigger_event_error(self, event: dict[str, Any]) -> None: - if "error_type" == "timeout": + if event["error_type"] == "timeout": raise HITLTimeoutError(event) raise HITLTriggerEventError(event) diff --git a/providers/standard/tests/unit/standard/operators/test_hitl.py b/providers/standard/tests/unit/standard/operators/test_hitl.py index 7735a8c04c9..f198cc461cf 100644 --- a/providers/standard/tests/unit/standard/operators/test_hitl.py +++ b/providers/standard/tests/unit/standard/operators/test_hitl.py @@ -18,6 +18,8 @@ from __future__ import annotations import pytest +from airflow.providers.standard.exceptions import HITLTimeoutError, HITLTriggerEventError + from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS if not AIRFLOW_V_3_1_PLUS: @@ -249,6 +251,28 @@ class TestHITLOperator: "responded_by_user": {"id": "test", "name": "test"}, } + @pytest.mark.parametrize( + "event, expected_exception", + [ + ({"error": "unknown", "error_type": "unknown"}, HITLTriggerEventError), + ({"error": "this is timeotu", "error_type": "timeout"}, HITLTimeoutError), + ], + ) + def test_process_trigger_event_error( + self, + event: dict[str, Any], + expected_exception, + ) -> None: + hitl_op = HITLOperator( + task_id="hitl_test", + subject="This is subject", + body="This is body", + options=["1", "2", "3", "4", "5"], + params={"input": 1}, + ) + with pytest.raises(expected_exception): + hitl_op.process_trigger_event_error(event) + def test_validate_chosen_options_with_invalid_content(self) -> None: hitl_op = HITLOperator( task_id="hitl_test",
