Skip to content

Commit 720df57

Browse files
authored
fix(hitl): Fix HITLEntryOperator "options" and "defaults" handling (apache#53184)
Only when both are not provided will they be set to ["OK"]
1 parent 912ccac commit 720df57

File tree

2 files changed

+28
-2
lines changed
  • providers/standard

2 files changed

+28
-2
lines changed

providers/standard/src/airflow/providers/standard/operators/hitl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ class HITLEntryOperator(HITLOperator):
227227
def __init__(self, **kwargs) -> None:
228228
if "options" not in kwargs:
229229
kwargs["options"] = ["OK"]
230-
kwargs["defaults"] = ["OK"]
230+
231+
if "defaults" not in kwargs:
232+
kwargs["defaults"] = ["OK"]
231233

232234
super().__init__(**kwargs)

providers/standard/tests/unit/standard/operators/test_hitl.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_execute_complete_with_downstream_tasks(self, dag_maker) -> None:
257257

258258

259259
class TestHITLEntryOperator:
260-
def test_init(self) -> None:
260+
def test_init_without_options_and_default(self) -> None:
261261
op = HITLEntryOperator(
262262
task_id="hitl_test",
263263
subject="This is subject",
@@ -267,3 +267,27 @@ def test_init(self) -> None:
267267

268268
assert op.options == ["OK"]
269269
assert op.defaults == ["OK"]
270+
271+
def test_init_without_options(self) -> None:
272+
op = HITLEntryOperator(
273+
task_id="hitl_test",
274+
subject="This is subject",
275+
body="This is body",
276+
params={"input": 1},
277+
defaults=None,
278+
)
279+
280+
assert op.options == ["OK"]
281+
assert op.defaults is None
282+
283+
def test_init_without_default(self) -> None:
284+
op = HITLEntryOperator(
285+
task_id="hitl_test",
286+
subject="This is subject",
287+
body="This is body",
288+
params={"input": 1},
289+
options=["OK", "NOT OK"],
290+
)
291+
292+
assert op.options == ["OK", "NOT OK"]
293+
assert op.defaults is None

0 commit comments

Comments
 (0)