Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix table multiple pending changes

Carlos Monastyrski5cd6bf8213ab
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
index 559c868433..1f27d1c7b2 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
@@ -483,8 +483,8 @@ export const secretV2BridgeServiceFactory = ({
});
if (!sharedSecretToModify)
throw new NotFoundError({ message: `Secret with name ${inputSecret.secretName} not found` });
- if (sharedSecretToModify.isRotatedSecret && (inputSecret.newSecretName || inputSecret.secretValue))
- throw new BadRequestError({ message: "Cannot update rotated secret name or value" });
+ if (sharedSecretToModify.isRotatedSecret && inputSecret.newSecretName)
+ throw new BadRequestError({ message: "Cannot update rotated secret name" });
secretId = sharedSecretToModify.id;
secret = sharedSecretToModify;
}
@@ -1934,8 +1934,14 @@ export const secretV2BridgeServiceFactory = ({
if (el.isRotatedSecret) {
const input = secretsToUpdateGroupByPath[secretPath].find((i) => i.secretKey === el.key);
- if (input && (input.newSecretName || input.secretValue))
- throw new BadRequestError({ message: `Cannot update rotated secret name or value: ${el.key}` });
+ if (input) {
+ if (input.newSecretName) {
+ delete input.newSecretName;
+ }
+ if (input.secretValue !== undefined) {
+ delete input.secretValue;
+ }
+ }
}
});
@@ -2061,8 +2067,11 @@ export const secretV2BridgeServiceFactory = ({
commitChanges,
inputSecrets: secretsToUpdate.map((el) => {
const originalSecret = secretsToUpdateInDBGroupedByKey[el.secretKey][0];
+ const shouldUpdateValue = !originalSecret.isRotatedSecret && typeof el.secretValue !== "undefined";
+ const shouldUpdateName = !originalSecret.isRotatedSecret && el.newSecretName;
+
const encryptedValue =
- typeof el.secretValue !== "undefined"
+ shouldUpdateValue && el.secretValue !== undefined
? {
encryptedValue: secretManagerEncryptor({ plainText: Buffer.from(el.secretValue) }).cipherTextBlob,
references: secretReferencesGroupByInputSecretKey[el.secretKey]?.nestedReferences
@@ -2077,7 +2086,7 @@ export const secretV2BridgeServiceFactory = ({
(value) => secretManagerEncryptor({ plainText: Buffer.from(value) }).cipherTextBlob
),
skipMultilineEncoding: el.skipMultilineEncoding,
- key: el.newSecretName || el.secretKey,
+ key: shouldUpdateName ? el.newSecretName : el.secretKey,
tags: el.tagIds,
secretMetadata: el.secretMetadata,
...encryptedValue
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
index be5dfaaedc..b6d358453b 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
@@ -52,6 +52,7 @@ type Props = {
}[];
}[];
colWidth: number;
+ excludePendingCreates?: boolean;
};
export const SecretListView = ({
@@ -64,7 +65,8 @@ export const SecretListView = ({
isProtectedBranch = false,
usedBySecretSyncs,
importedBy,
- colWidth
+ colWidth,
+ excludePendingCreates = false
}: Props) => {
const queryClient = useQueryClient();
const { popUp, handlePopUpToggle, handlePopUpOpen, handlePopUpClose } = usePopUp([
@@ -580,27 +582,32 @@ export const SecretListView = ({
{FontAwesomeSpriteSymbols.map(({ icon, symbol }) => (
<FontAwesomeIcon icon={icon} symbol={symbol} key={`font-awesome-svg-spritie-${symbol}`} />
))}
- {secrets.map((secret) => (
- <SecretItem
- colWidth={colWidth}
- environment={environment}
- secretPath={secretPath}
- tags={wsTags}
- isSelected={Boolean(selectedSecrets?.[secret.id])}
- onToggleSecretSelect={toggleSelectedSecret}
- isVisible={isVisible}
- secret={secret}
- key={secret.id}
- onSaveSecret={handleSaveSecret}
- onDeleteSecret={onDeleteSecret}
- onDetailViewSecret={onDetailViewSecret}
- importedBy={importedBy}
- onCreateTag={onCreateTag}
- onShareSecret={onShareSecret}
- isPending={secret.isPending}
- pendingAction={secret.pendingAction}
- />
- ))}
+ {secrets
+ .filter((secret) => {
+ if (!excludePendingCreates) return true;
+ return !secret.isPending || secret.pendingAction !== PendingAction.Create;
+ })
+ .map((secret) => (
+ <SecretItem
+ colWidth={colWidth}
+ environment={environment}
+ secretPath={secretPath}
+ tags={wsTags}
+ isSelected={Boolean(selectedSecrets?.[secret.id])}
+ onToggleSecretSelect={toggleSelectedSecret}
+ isVisible={isVisible}
+ secret={secret}
+ key={secret.id}
+ onSaveSecret={handleSaveSecret}
+ onDeleteSecret={onDeleteSecret}
+ onDetailViewSecret={onDetailViewSecret}
+ importedBy={importedBy}
+ onCreateTag={onCreateTag}
+ onShareSecret={onShareSecret}
+ isPending={secret.isPending}
+ pendingAction={secret.pendingAction}
+ />
+ ))}
<DeleteActionModal
isOpen={popUp.deleteSecret.isOpen}
deleteKey={(popUp.deleteSecret?.data as SecretV3RawSanitized)?.key}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
index e18547d1e9..9764959e30 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretRotationListView/SecretRotationItem.tsx
@@ -253,6 +253,7 @@ export const SecretRotationItem = ({
isProtectedBranch={isProtectedBranch}
importedBy={importedBy}
usedBySecretSyncs={usedBySecretSyncs}
+ excludePendingCreates
/>
)}
<Modal onOpenChange={setShowSecrets} isOpen={showSecrets}>