jason810496 commented on code in PR #64108:
URL: https://github.com/apache/airflow/pull/64108#discussion_r2978745172


##########
providers/standard/newsfragments/64108.bugfix.rst:
##########
@@ -0,0 +1 @@
+Fix HITLOperator ``ParamValidationError`` when params lack default values at 
DAG import time

Review Comment:
   No need to add `providers/standard/newsfragments/64108.bugfix.rst`, could 
you please remove it, thanks.



##########
providers/standard/tests/unit/standard/operators/test_hitl.py:
##########
@@ -139,37 +139,67 @@ def test_validate_options_with_empty_options(self) -> 
None:
                 params=ParamsDict({"input_1": 1}),
             )
 
-    @pytest.mark.parametrize(
-        ("params", "exc", "error_msg"),
-        (
-            (ParamsDict({"_options": 1}), ValueError, '"_options" is not 
allowed in params'),
-            (
-                ParamsDict({"param": Param("", type="integer")}),
-                ParamValidationError,
-                (
-                    "Invalid input for param param: '' is not of type 
'integer'\n\n"
-                    "Failed validating 'type' in schema:\n"
-                    "    {'type': 'integer'}\n\n"
-                    "On instance:\n    ''"
-                ),
-            ),
-        ),
-    )
-    def test_validate_params(
-        self, params: ParamsDict, exc: type[ValueError | 
ParamValidationError], error_msg: str
-    ) -> None:
-        # validate_params is called during initialization
-        with pytest.raises(exc, match=error_msg):
+    def test_validate_params_rejects_options_key(self) -> None:
+        """_options is a reserved key and must not be allowed in params."""
+        with pytest.raises(ValueError, match='"_options" is not allowed in 
params'):
             HITLOperator(
                 task_id="hitl_test",
                 subject="This is subject",
                 options=["1", "2"],
                 body="This is body",
                 defaults=["1"],
                 multiple=False,
-                params=params,
+                params=ParamsDict({"_options": 1}),
             )
 

Review Comment:
   All the test cases make sense to me. Could you please consolidate these 
tests with parameterize? Thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to