Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
rethrow on compatibility shym
Thiago Araujo da Silva3acf5dd31ebe
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.test.ts b/backend/src/ee/services/audit-log/audit-log-queue.test.tsindex 9bb2b1e762..49679b11e3 100644--- a/backend/src/ee/services/audit-log/audit-log-queue.test.ts+++ b/backend/src/ee/services/audit-log/audit-log-queue.test.ts@@ -152,6 +152,15 @@ describe("audit-log-queue pushToLog", () => {expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);});++ test("compatibility shim re-throws on streamAdd failure so BullMQ retries the legacy job", async () => {+ const { shim, keyStore } = await createHarness();+ keyStore.streamAdd.mockRejectedValueOnce(new Error("redis down"));++ await expect(+ shim({ data: { event: { type: "e", metadata: {} }, actor: { type: "platform", metadata: {} }, orgId: "o" } })+ ).rejects.toThrow("redis down");+ });});describe("audit-log-queue unified consumer", () => {diff --git a/backend/src/ee/services/audit-log/audit-log-queue.ts b/backend/src/ee/services/audit-log/audit-log-queue.tsindex 55e2664827..9137c435db 100644--- a/backend/src/ee/services/audit-log/audit-log-queue.ts+++ b/backend/src/ee/services/audit-log/audit-log-queue.ts@@ -80,12 +80,18 @@ export const auditLogQueueServiceFactory = async ({// retry (reprocessing the same batch after a failed insert) re-inserts byte-identical rows// instead of regenerating ids. UUIDv7 embeds the timestamp for ClickHouse's time-sorted id;// UUIDv4 keeps the existing Postgres schema expectation.+ const appendToIngestStream = async (data: TCreateAuditLogDTO) => {+ const createdAt = new Date();+ const id = isClickHouseBatchEnabled ? uuidv7({ msecs: createdAt.getTime() }) : randomUUID();+ const entry: TAuditLogStreamEntry = { ...data, id, createdAt: createdAt.toISOString() };+ await keyStore.streamAdd(AUDIT_LOG_STREAM_KEY, "*", { data: JSON.stringify(entry) });+ };++ // Request-path push: a transient Redis failure must not fail the request that produced+ // the audit event, so errors are logged and swallowed (at-most-once on this path).const pushToLog = async (data: TCreateAuditLogDTO) => {try {- const createdAt = new Date();- const id = isClickHouseBatchEnabled ? uuidv7({ msecs: createdAt.getTime() }) : randomUUID();- const entry: TAuditLogStreamEntry = { ...data, id, createdAt: createdAt.toISOString() };- await keyStore.streamAdd(AUDIT_LOG_STREAM_KEY, "*", { data: JSON.stringify(entry) });+ await appendToIngestStream(data);} catch (error) {logger.error(error,@@ -96,11 +102,12 @@ export const auditLogQueueServiceFactory = async ({// Compatibility shim: legacy per-log AuditLog jobs enqueued by old pods (before the// stream rollout) get re-routed into the unified stream so a rolling deploy doesn't- // strand them with no consumer.+ // strand them with no consumer. Unlike the request path we re-throw on stream-add+ // failure so BullMQ retries the job instead of dropping it.// TODO: remove next release once the legacy QueueName.AuditLog queue has drained.queueService.start(QueueName.AuditLog, async (job) => {if (!job.data) return;- await pushToLog(job.data);+ await appendToIngestStream(job.data);});const insertBatch = async (logs: TAuditLogs[]) => {