ashb commented on code in PR #27063:
URL: https://github.com/apache/airflow/pull/27063#discussion_r1066756429
##########
airflow/www/views.py:
##########
@@ -1955,7 +1963,32 @@ def trigger(self, session=None):
request_execution_date = request.values.get("execution_date",
default=timezone.utcnow().isoformat())
is_dag_run_conf_overrides_params = conf.getboolean("core",
"dag_run_conf_overrides_params")
dag = get_airflow_app().dag_bag.get_dag(dag_id)
- dag_orm = session.query(DagModel).filter(DagModel.dag_id ==
dag_id).first()
+ dag_orm: DagModel = session.query(DagModel).filter(DagModel.dag_id ==
dag_id).first()
+
+ # Prepare form fields with param struct details to render a proper
form with schema information
+ form_fields = {}
+ for k, v in dag.params.items():
+ form_fields[k] = v.dump()
+ # If no schema is provided, auto-detect on default values
+ if "schema" not in form_fields[k]:
+ form_fields[k]["schema"] = {}
+ if "type" not in form_fields[k]["schema"]:
+ if isinstance(form_fields[k]["value"], bool):
+ form_fields[k]["schema"]["type"] = "boolean"
+ elif isinstance(form_fields[k]["value"], int):
+ form_fields[k]["schema"]["type"] = ["integer", "null"]
+ elif isinstance(form_fields[k]["value"], list):
+ form_fields[k]["schema"]["type"] = ["array", "null"]
+ elif isinstance(form_fields[k]["value"], dict):
+ form_fields[k]["schema"]["type"] = ["object", "null"]
+ # Mark markup fields as safe
+ if "description" in form_fields[k] and
form_fields[k]["description"]:
+ form_fields[k]["description"] =
Markup(form_fields[k]["description"])
Review Comment:
I don't think this is safe -- it means of someone puts a description of
"field must be < x" it'd break. Using HTML is the exception in my mind, so make
the users use this if they want to include HTML
--
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]