shivaam commented on code in PR #74569:
URL: https://github.com/apache/airflow/pull/74569#discussion_r4405155451
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -100,6 +105,43 @@ def __getattr__(self, name: str) -> Any:
return getattr(self.value, name)
+def _check_params_input(params: Mapping[str, Any], params_input: Mapping[str,
Any]) -> str | None:
+ """
+ Return why ``params_input`` is not a valid answer to the request's
``params``, or None.
+
+ Mirrors ``HITLOperator.validate_params_input``: when both are given, the
answer must name exactly
+ the declared params, and each value must pass its param's JSON Schema. A
param stored without a
+ schema, as older providers store it, accepts any value.
+ """
+ if not params or not params_input:
+ return None
+ if set(params) != set(params_input):
+ return f"params_input {sorted(params_input)} does not match params
{sorted(params)}."
+ answers = SerializedParamsDict(
+ {key: _answer_param(value, params[key]) for key, value in
params_input.items()}
+ )
+ try:
+ answers.validate()
+ except ParamValidationError as e:
+ return str(e)
+ return None
+
+
+def _answer_param(value: Any, spec: Any) -> SerializedParam:
Review Comment:
Renamed to `_build_answer_param`.
---
Drafted-by: Claude Code (Opus 5.5); reviewed by @shivaam before posting
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py:
##########
@@ -100,6 +105,43 @@ def __getattr__(self, name: str) -> Any:
return getattr(self.value, name)
+def _check_params_input(params: Mapping[str, Any], params_input: Mapping[str,
Any]) -> str | None:
Review Comment:
Done: `_validate_params_input` now raises `ParamValidationError`, and the
route catches it and returns 400, like the Dag-run trigger route.
---
Drafted-by: Claude Code (Opus 5.5); reviewed by @shivaam before posting
--
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]