fix: resolved approval failing when secret was missing in board

This commit is contained in:
=
2024-05-31 23:10:03 +05:30
parent d6fcba9169
commit f426025fd5
@@ -139,18 +139,25 @@ export const secretReplicationServiceFactory = ({
}); });
const localSecretsGroupedByBlindIndex = groupBy(localSecrets, (i) => i.secretBlindIndex as string); const localSecretsGroupedByBlindIndex = groupBy(localSecrets, (i) => i.secretBlindIndex as string);
const locallyCreatedSecrets = sanitizedSecrets.filter(({ operation, id }) => { const locallyCreatedSecrets = sanitizedSecrets
return ( .filter(
(operation === SecretOperations.Create || operation === SecretOperations.Update) && ({ operation, id }) =>
!localSecretsGroupedByBlindIndex[replicatedSecretsGroupBySecretId[id][0].secretBlindIndex as string]?.[0] // upsert: irrespective of create or update its a create if not found in dashboard
); (operation === SecretOperations.Create || operation === SecretOperations.Update) &&
}); !localSecretsGroupedByBlindIndex[
replicatedSecretsGroupBySecretId[id][0].secretBlindIndex as string
]?.[0]
)
.map((el) => ({ ...el, operation: SecretOperations.Create })); // rewrite update ops to create
const locallyUpdatedSecrets = sanitizedSecrets.filter( const locallyUpdatedSecrets = sanitizedSecrets
({ operation, id }) => .filter(
(operation === SecretOperations.Create || operation === SecretOperations.Update) && ({ operation, id }) =>
localSecretsGroupedByBlindIndex[replicatedSecretsGroupBySecretId[id][0].secretBlindIndex as string]?.[0] // upsert: irrespective of create or update its an update if not found in dashboard
); (operation === SecretOperations.Create || operation === SecretOperations.Update) &&
localSecretsGroupedByBlindIndex[replicatedSecretsGroupBySecretId[id][0].secretBlindIndex as string]?.[0]
)
.map((el) => ({ ...el, operation: SecretOperations.Update })); // rewrite create ops to update
const locallyDeletedSecrets = sanitizedSecrets.filter( const locallyDeletedSecrets = sanitizedSecrets.filter(
({ operation, id }) => ({ operation, id }) =>
@@ -196,6 +203,7 @@ export const secretReplicationServiceFactory = ({
.map(({ id, operation }) => { .map(({ id, operation }) => {
const doc = replicatedSecretsGroupBySecretId[id][0]; const doc = replicatedSecretsGroupBySecretId[id][0];
const localSecret = localSecretsGroupedByBlindIndex[doc.secretBlindIndex as string]?.[0]; const localSecret = localSecretsGroupedByBlindIndex[doc.secretBlindIndex as string]?.[0];
return { return {
op: operation, op: operation,
keyEncoding: doc.keyEncoding, keyEncoding: doc.keyEncoding,