Skip to content

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

Merge branch 'main' into chore/update-secrets-metrics

Victor Hugo dos Santos7a26986b45a2
diff --cc backend/src/services/secret-sync/secret-sync-queue.ts
index b092e5d67b,3c176237b8..bf47b1e1a2
--- a/backend/src/services/secret-sync/secret-sync-queue.ts
+++ b/backend/src/services/secret-sync/secret-sync-queue.ts
@@@ -641,35 -646,16 +650,39 @@@ export const secretSyncQueueFactory = (
});
if (isSynced || isFinalAttempt) {
+ // lastSyncResult is written only here, so lock and admission failures cannot overwrite the provider's result.
+ // The conditional update makes only the run that actually changes it report the change, whatever state this
+ // job loaded before taking the lock. A sync that never succeeded (null) failing is a new misconfiguration, not
+ // a breakage, so it is not counted.
+ const isStatusChange =
+ (
+ await secretSyncDAL.update(
+ {
+ id: secretSync.id,
+ lastSyncResult: isSynced ? SecretSyncStatus.Failed : SecretSyncStatus.Succeeded
+ },
+ { lastSyncResult: syncStatus }
+ )
+ ).length > 0;
+
+ if (isStatusChange) {
+ recordSecretSyncStatusChangeMetric({
+ destination: secretSync.destination,
+ newStatus: isSynced ? "healthy" : "failed"
+ });
+ }
+
- const updatedSecretSync = await secretSyncDAL.updateById(secretSync.id, {
- syncStatus,
- lastSyncJobId: job.id,
- lastSyncMessage: syncMessage,
- lastSyncedAt: isSynced ? ranAt : undefined,
- lastSyncResult: syncStatus
- });
+ const updatedSecretSync = await secretSyncDAL.updateById(
+ secretSync.id,
+ {
+ syncStatus,
+ lastSyncJobId: job.id,
+ lastSyncMessage: syncMessage,
- lastSyncedAt: isSynced ? ranAt : undefined
++ lastSyncedAt: isSynced ? ranAt : undefined,
++ lastSyncResult: syncStatus
+ },
+ { includeFolderPath: false }
+ );
if (!isSynced) {
void telemetryService