bbovenzi commented on code in PR #59533:
URL: https://github.com/apache/airflow/pull/59533#discussion_r2669058846
##########
airflow-core/src/airflow/ui/src/pages/Connections/ConnectionForm.tsx:
##########
@@ -97,32 +97,27 @@ const ConnectionForm = ({
};
// Check if extra fields have changed by comparing with initial connection
- const isExtraFieldsDirty = (() => {
- try {
- const initialParsed = JSON.parse(initialConnection.extra) as
Record<string, unknown>;
- const currentParsed = JSON.parse(extra) as Record<string, unknown>;
+ let isExtraFieldsDirty: boolean;
- return JSON.stringify(initialParsed) !== JSON.stringify(currentParsed);
- } catch {
- // If parsing fails, fall back to string comparison
- return extra !== initialConnection.extra;
- }
- })();
+ try {
+ const initialParsed = JSON.parse(initialConnection.extra) as
Record<string, unknown>;
+ const currentParsed = JSON.parse(extra) as Record<string, unknown>;
+
+ isExtraFieldsDirty = JSON.stringify(initialParsed) !==
JSON.stringify(currentParsed);
+ } catch {
+ // If parsing fails, fall back to string comparison
+ isExtraFieldsDirty = extra !== initialConnection.extra;
+ }
const validateAndPrettifyJson = (value: string) => {
try {
- if (value.trim() === "") {
- setErrors((prev) => ({ ...prev, conf: undefined }));
+ setErrors((prev) => ({ ...prev, conf: undefined }));
+ if (value.trim() === "") {
return value;
}
- const parsedJson = JSON.parse(value) as Record<string, unknown>;
-
- if (typeof parsedJson !== "object" || Array.isArray(parsedJson)) {
- throw new TypeError('extra fields must be a valid JSON object (e.g.,
{"key": "value"})');
- }
Review Comment:
We didn't need this. JsonEditor already creates an error when the input is
not valid json
--
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]