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:
Enzo Martellucci
2026-05-06 12:32:10 +02:00
parent 864b27d0e3
commit 3e26f0218f
2 changed files with 11 additions and 5 deletions

View File

@@ -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 = () => {

View File

@@ -909,7 +909,7 @@ export function useDatabaseValidation() {
setIsValidating(false);
setHasValidated(true);
}
return {};
return null;
}
},
[setValidationErrors],