This is an automated email from the ASF dual-hosted git repository.

jscheffl 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 6eab1f24c2f Fix update issues for object and advanced-arrays fields 
when empty default (#45313)
6eab1f24c2f is described below

commit 6eab1f24c2fe070b6d68a1435eadaccd807ed1c0
Author: Jens Scheffler <[email protected]>
AuthorDate: Tue Dec 31 20:56:09 2024 +0100

    Fix update issues for object and advanced-arrays fields when empty default 
(#45313)
---
 airflow/www/static/js/trigger.js           | 4 ++--
 airflow/www/templates/airflow/trigger.html | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/airflow/www/static/js/trigger.js b/airflow/www/static/js/trigger.js
index 7a3444f460f..9242984e75b 100644
--- a/airflow/www/static/js/trigger.js
+++ b/airflow/www/static/js/trigger.js
@@ -59,8 +59,6 @@ function updateJSONconf() {
           }
         }
         params[keyName] = values.length === 0 ? null : values;
-      } else if (elements[i].value.length === 0) {
-        params[keyName] = null;
       } else if (
         elements[i].attributes.valuetype &&
         (elements[i].attributes.valuetype.value === "object" ||
@@ -81,6 +79,8 @@ function updateJSONconf() {
           // ignore JSON parsing errors
           // we don't want to bother users during entry, error will be 
displayed before submit
         }
+      } else if (elements[i].value.length === 0) {
+        params[keyName] = null;
       } else if (Number.isNaN(elements[i].value)) {
         params[keyName] = elements[i].value;
       } else if (
diff --git a/airflow/www/templates/airflow/trigger.html 
b/airflow/www/templates/airflow/trigger.html
index d68f4fc97b8..ff8be7870fd 100644
--- a/airflow/www/templates/airflow/trigger.html
+++ b/airflow/www/templates/airflow/trigger.html
@@ -118,7 +118,9 @@
     {% elif form_details.schema and "object" in form_details.schema.type %}
       <textarea class="form-control" name="element_{{ form_key }}" 
id="element_{{ form_key }}" valuetype="object" rows="6"
         {%- if not "null" in form_details.schema.type %} required=""{% endif 
-%}>
-        {{- form_details.value | tojson() -}}
+        {%- if form_details.value %}
+          {{- form_details.value | tojson() -}}
+        {% endif -%}
       </textarea>
     {% elif form_details.schema and ("integer" in form_details.schema.type or 
"number" in form_details.schema.type) %}
       <input class="form-control" name="element_{{ form_key }}" id="element_{{ 
form_key }}"

Reply via email to