diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.tsx index 8474cde2af6..bd9a26084af 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.tsx @@ -823,13 +823,19 @@ const DatabaseModal: FunctionComponent = ({ [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 = () => { diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts index b7dae7a1e4f..4cb9e9f9c97 100644 --- a/superset-frontend/src/views/CRUD/hooks.ts +++ b/superset-frontend/src/views/CRUD/hooks.ts @@ -909,7 +909,7 @@ export function useDatabaseValidation() { setIsValidating(false); setHasValidated(true); } - return {}; + return null; } }, [setValidationErrors],