Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: refresh policy before create (#19992)

ecmadao7f0944e08cf9
diff --git a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
index cba96b8fe3..3961e1fa50 100644
--- a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
+++ b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
@@ -241,6 +241,7 @@ export function ProjectMaskingExemptionCreatePage({
const policy = await policyStore.getOrFetchPolicyByParentAndType({
parentPath: projectName,
policyType: PolicyType.MASKING_EXEMPTION,
+ refresh: true,
});
const existed =
policy?.policy?.case === "maskingExemptionPolicy"
diff --git a/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx b/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx
index 73bb66e664..0256c051d7 100644
--- a/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx
+++ b/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx
@@ -622,6 +622,7 @@ function useExemptionDataReact(projectName: string) {
const pol = await policyStore.getOrFetchPolicyByParentAndType({
parentPath: projectName,
policyType: PolicyType.MASKING_EXEMPTION,
+ refresh: true,
});
if (generation !== fetchGenRef.current) return;
@@ -717,12 +718,10 @@ function useExemptionDataReact(projectName: string) {
processingRef.current = false;
return;
}
-
- const [removed] = currentList.splice(idx, 1);
- setRawAccessList(currentList);
+ currentList.splice(idx, 1);
try {
- // Rebuild and save policy
+ // Rebuild and save policy first; only update UI state on success.
const pol = await policyStore.getOrFetchPolicyByParentAndType({
parentPath: projectName,
policyType: PolicyType.MASKING_EXEMPTION,
@@ -739,16 +738,13 @@ function useExemptionDataReact(projectName: string) {
policy: pol,
});
}
+ setRawAccessList(currentList);
pushNotification({
module: "bytebase",
style: "SUCCESS",
title: t("common.updated"),
});
} catch (error) {
- // Restore on failure
- const restored = [...rawAccessListRef.current];
- restored.splice(idx, 0, removed);
- setRawAccessList(restored);
pushNotification({
module: "bytebase",
style: "CRITICAL",