This is an automated email from the ASF dual-hosted git repository.
weilee 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 f697a0b0ee7 fix Preserve variable value formatting in edit dialog
(#58757)
f697a0b0ee7 is described below
commit f697a0b0ee79012b19d7af155b9f67cb8247e107
Author: RickyChen / 陳昭儒 <[email protected]>
AuthorDate: Sat Nov 29 11:00:39 2025 +0800
fix Preserve variable value formatting in edit dialog (#58757)
---
.../pages/Variables/ManageVariable/EditVariableButton.tsx | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git
a/airflow-core/src/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx
b/airflow-core/src/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx
index 4310a2f92ff..312cb27c762 100644
---
a/airflow-core/src/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx
+++
b/airflow-core/src/airflow/ui/src/pages/Variables/ManageVariable/EditVariableButton.tsx
@@ -33,13 +33,24 @@ type Props = {
readonly variable: VariableResponse;
};
+const formatValue = (value: string): string => {
+ try {
+ const parsed: unknown = JSON.parse(value);
+
+ return JSON.stringify(parsed, undefined, 2);
+ } catch {
+ return value;
+ }
+};
+
const EditVariableButton = ({ disabled, variable }: Props) => {
const { t: translate } = useTranslation("admin");
const { onClose, onOpen, open } = useDisclosure();
+
const initialVariableValue: VariableBody = {
description: variable.description ?? "",
key: variable.key,
- value: variable.value,
+ value: formatValue(variable.value),
};
const { editVariable, error, isPending, setError } =
useEditVariable(initialVariableValue, {
onSuccessConfirm: onClose,