Skip to content

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

fix(audit-log-stream): keep the drop reason update from reviving a cleared stream error

Calvin6ce02613d36c
diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-dal.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-dal.ts
index eb5317aea2..5f1356aee3 100644
--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-dal.ts
+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-dal.ts
@@ -313,7 +313,12 @@ export const auditLogStreamOutboxDALFactory = (db: TDbClient) => {
.returning<{ failingSince: Date }[]>("failingSince");
if (row) return row.failingSince;
- await tx(TableName.AuditLogStream).where("id", streamId).update({ lastDeliveryError: errorMessage });
+ // Guarded so a credential update that cleared the health fields between the two statements is
+ // not undone, since clearStreamFailing would then never clear the stale error.
+ await tx(TableName.AuditLogStream)
+ .where("id", streamId)
+ .whereNotNull("failingSince")
+ .update({ lastDeliveryError: errorMessage });
return null;
} catch (error) {
throw new DatabaseError({ error, name: "AuditLogStreamOutbox: markStreamFailing" });