rusackas commented on code in PR #40628:
URL: https://github.com/apache/superset/pull/40628#discussion_r3342416462
##########
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx:
##########
@@ -63,10 +63,16 @@ export const EncryptedField = ({
encryptedCredentialsMap[db.engine as keyof typeof encryptedCredentialsMap];
const paramValue =
db?.parameters?.[encryptedField as keyof DatabaseParameters];
+ // In edit mode the backend may return the existing (masked) credential in
+ // the parameters. Do not surface any pre-existing value in the field; the
+ // user must re-enter credentials to change them. This also matches the
+ // mount effect below, which resets the parameter to an empty string.
const encryptedValue =
- paramValue && typeof paramValue === 'object'
- ? JSON.stringify(paramValue)
- : paramValue;
+ isEditMode || !paramValue
+ ? ''
+ : typeof paramValue === 'object'
+ ? JSON.stringify(paramValue)
+ : paramValue;
Review Comment:
Good catch — switched to a nullish check (`paramValue == null`) so
legitimately falsy values like `false` or `0` are still serialized for display
in create mode, while edit mode unconditionally forces `''`. Fixed in a4dec9a.
##########
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx:
##########
@@ -173,13 +194,18 @@ describe('EncryptedField', () => {
},
];
Review Comment:
Added `true`/`false` cases to the create-mode parameter test matrix, and
paired with the nullish-check fix above so falsy-but-valid values are no longer
blanked out. Fixed in a4dec9a.
##########
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx:
##########
@@ -173,13 +194,18 @@ describe('EncryptedField', () => {
},
];
Review Comment:
Added the missing `true`/`false` boolean cases to `createModeCases`,
alongside switching the value guard to a nullish check so falsy values are
serialized rather than dropped. Fixed in a4dec9a.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]