This is an automated email from the ASF dual-hosted git repository.
weilee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 720df576c11 fix(hitl): Fix HITLEntryOperator "options" and "defaults"
handling (#53184)
720df576c11 is described below
commit 720df576c113572f157a367933eaced102d8ee18
Author: Wei Lee <[email protected]>
AuthorDate: Wed Jul 16 08:33:57 2025 +0200
fix(hitl): Fix HITLEntryOperator "options" and "defaults" handling (#53184)
Only when both are not provided will they be set to ["OK"]
---
.../airflow/providers/standard/operators/hitl.py | 4 +++-
.../tests/unit/standard/operators/test_hitl.py | 26 +++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git
a/providers/standard/src/airflow/providers/standard/operators/hitl.py
b/providers/standard/src/airflow/providers/standard/operators/hitl.py
index 6a1f88ddb44..54fee358214 100644
--- a/providers/standard/src/airflow/providers/standard/operators/hitl.py
+++ b/providers/standard/src/airflow/providers/standard/operators/hitl.py
@@ -227,6 +227,8 @@ class HITLEntryOperator(HITLOperator):
def __init__(self, **kwargs) -> None:
if "options" not in kwargs:
kwargs["options"] = ["OK"]
- kwargs["defaults"] = ["OK"]
+
+ if "defaults" not in kwargs:
+ kwargs["defaults"] = ["OK"]
super().__init__(**kwargs)
diff --git a/providers/standard/tests/unit/standard/operators/test_hitl.py
b/providers/standard/tests/unit/standard/operators/test_hitl.py
index 767c379bdc0..4781b425f7f 100644
--- a/providers/standard/tests/unit/standard/operators/test_hitl.py
+++ b/providers/standard/tests/unit/standard/operators/test_hitl.py
@@ -257,7 +257,7 @@ class TestApprovalOperator:
class TestHITLEntryOperator:
- def test_init(self) -> None:
+ def test_init_without_options_and_default(self) -> None:
op = HITLEntryOperator(
task_id="hitl_test",
subject="This is subject",
@@ -267,3 +267,27 @@ class TestHITLEntryOperator:
assert op.options == ["OK"]
assert op.defaults == ["OK"]
+
+ def test_init_without_options(self) -> None:
+ op = HITLEntryOperator(
+ task_id="hitl_test",
+ subject="This is subject",
+ body="This is body",
+ params={"input": 1},
+ defaults=None,
+ )
+
+ assert op.options == ["OK"]
+ assert op.defaults is None
+
+ def test_init_without_default(self) -> None:
+ op = HITLEntryOperator(
+ task_id="hitl_test",
+ subject="This is subject",
+ body="This is body",
+ params={"input": 1},
+ options=["OK", "NOT OK"],
+ )
+
+ assert op.options == ["OK", "NOT OK"]
+ assert op.defaults is None