mirror of
https://github.com/apache/superset.git
synced 2026-05-29 20:29:34 +00:00
fix(database): retry blur validation after a transient request failure
When the validate_parameters request failed without a structured error body (e.g. network drop), getValidation returned an empty object that the caller could not distinguish from "validation passed" — and the blur dedup cache was already updated, so the same form state would never revalidate until the user changed a field. Have getValidation return null on unexpected failure and only update the snapshot cache after a usable response. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -823,13 +823,19 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
[onChange, handleClearValidationErrors],
|
||||
);
|
||||
|
||||
const getBlurValidation = useCallback(() => {
|
||||
const getBlurValidation = useCallback(async () => {
|
||||
const currentDbSnapshot = JSON.stringify(db);
|
||||
if (currentDbSnapshot === lastValidatedDbSnapshotRef.current) {
|
||||
return Promise.resolve([]);
|
||||
return [];
|
||||
}
|
||||
lastValidatedDbSnapshotRef.current = currentDbSnapshot;
|
||||
return getValidation(db);
|
||||
const result = await getValidation(db);
|
||||
// Only cache after a request that produced a usable response. ``null``
|
||||
// signals an unexpected/network failure, in which case we leave the
|
||||
// snapshot untouched so the next blur retries.
|
||||
if (result !== null) {
|
||||
lastValidatedDbSnapshotRef.current = currentDbSnapshot;
|
||||
}
|
||||
return result;
|
||||
}, [db, getValidation]);
|
||||
|
||||
const onClose = () => {
|
||||
|
||||
@@ -909,7 +909,7 @@ export function useDatabaseValidation() {
|
||||
setIsValidating(false);
|
||||
setHasValidated(true);
|
||||
}
|
||||
return {};
|
||||
return null;
|
||||
}
|
||||
},
|
||||
[setValidationErrors],
|
||||
|
||||
Reference in New Issue
Block a user