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
remove legacy compatibility
Thiago Araujo da Silva75cc767c7dda
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 3b068b3ae9..dc162f5b83 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@@ -26,7 +26,7 @@ vi.mock("@app/lib/logger", () => ({const STREAM_KEY = "audit-log-stream";const MS_IN_DAY = 24 * 60 * 60 * 1000;-// A push-time DTO (what pushToLog / the legacy shim receive — no resolved metadata yet).+// A push-time DTO (what pushToLog receives — no resolved metadata yet).const dto = (overrides: Record<string, unknown> = {}) => ({event: { type: "test-event", metadata: { k: "v" } },actor: { type: "platform", metadata: {} },@@ -46,23 +46,6 @@ const streamEntry = (overrides: Record<string, unknown> = {}) => ({...overrides});-const legacyEntry = (overrides: Record<string, unknown> = {}) => ({- id: "legacy-1",- actor: "platform",- actorMetadata: { k: "v" },- ipAddress: "",- eventType: "legacy-event",- eventMetadata: { e: "m" },- userAgent: "",- userAgentType: "",- projectId: "",- orgId: "org-1",- createdAt: new Date("2026-05-27T00:00:00.000Z").toISOString(),- expiresAt: new Date("2026-06-26T00:00:00.000Z").toISOString(),- updatedAt: new Date("2026-05-27T00:00:00.000Z").toISOString(),- ...overrides-});-// streamCollect returns [entryId, ["data", json]] tuples; the consumer parses fields[1].const collectResult = (payloads: Record<string, unknown>[], lastId = "9-0") => ({entries: payloads.map((p, i) => [`${i + 1}-0`, ["data", JSON.stringify(p)]] as [string, string[]]),@@ -141,8 +124,7 @@ const createHarness = async ({ clickhouse = false, streamsEnabled = false } = {}licenseService,auditLogStreamOutboxService,clickhouseClient,- consumer: startHandlers.get(QueueName.AuditLogClickHouseBatch)!,- shim: startHandlers.get(QueueName.AuditLog)!+ consumer: startHandlers.get(QueueName.AuditLogClickHouseBatch)!};};@@ -236,21 +218,6 @@ describe("audit-log-queue pushToLog", () => {await expect(service.pushToLog(dto({ orgId: "o" }) as never)).resolves.toBeUndefined();expect(keyStore.streamAdd).not.toHaveBeenCalled();});-- test("compatibility shim re-routes legacy jobs into the stream", async () => {- const { shim, keyStore } = await createHarness();-- await shim({ data: dto({ orgId: "o" }) });-- 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: dto({ orgId: "o" }) })).rejects.toThrow("redis down");- });});describe("audit-log-queue unified consumer", () => {@@ -398,51 +365,6 @@ describe("audit-log-queue unified consumer", () => {expect(rows[0].id).toBe("ok");});- test("drains legacy flat entries (rolling deploy) instead of choking on the missing event object", async () => {- const { consumer, clickhouseClient, keyStore } = await createHarness({ clickhouse: true });- keyStore.streamCollect.mockResolvedValueOnce(collectResult([legacyEntry({ id: "legacy-A" })]));-- await consumer();-- expect(clickhouseClient!.insert).toHaveBeenCalledTimes(1);- const row = clickhouseClient!.insert.mock.calls[0][0].values[0];- expect(row.id).toBe("legacy-A");- expect(row.actor).toBe("platform");- expect(row.eventType).toBe("legacy-event");- // timestamps are re-hydrated from ISO strings into Date instances for insertion- expect(row.createdAt).toBeInstanceOf(Date);- expect(row.expiresAt).toBeInstanceOf(Date);- expect(keyStore.streamTrim).toHaveBeenCalledWith(STREAM_KEY, "9-0", true);- });-- test("a legacy entry at the head does not abort the batch (no poison-pill stall)", async () => {- const { consumer, clickhouseClient, keyStore } = await createHarness({ clickhouse: true });- keyStore.streamCollect.mockResolvedValueOnce(- collectResult([legacyEntry({ id: "legacy-head" }), streamEntry({ id: "current-tail" })])- );-- await consumer();-- // both shapes mapped and inserted in the same batch, then trimmed- const rows = clickhouseClient!.insert.mock.calls[0][0].values;- expect(rows.map((r: Record<string, unknown>) => r.id)).toEqual(["legacy-head", "current-tail"]);- expect(keyStore.streamTrim).toHaveBeenCalledTimes(1);- });-- test("drops a legacy entry missing resolved metadata but keeps draining", async () => {- const { consumer, auditLogDAL, keyStore } = await createHarness();- keyStore.streamCollect.mockResolvedValueOnce(- collectResult([legacyEntry({ id: "no-org", orgId: undefined }), legacyEntry({ id: "ok" })])- );-- await consumer();-- const rows = auditLogDAL.batchCreate.mock.calls[0][0];- expect(rows).toHaveLength(1);- expect(rows[0].id).toBe("ok");- expect(keyStore.streamTrim).toHaveBeenCalledTimes(1);- });-test("skips the tick when the consumer lock is already held by another runner", async () => {const { consumer, auditLogDAL, keyStore, release } = await createHarness();keyStore.acquireLock.mockRejectedValueOnce(new Error("ResourceLockedError"));diff --git a/backend/src/ee/services/audit-log/audit-log-queue.ts b/backend/src/ee/services/audit-log/audit-log-queue.tsindex e7fd24e341..867e6451fe 100644--- a/backend/src/ee/services/audit-log/audit-log-queue.ts+++ b/backend/src/ee/services/audit-log/audit-log-queue.ts@@ -159,16 +159,6 @@ 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. 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 appendToIngestStream(job.data);- });-const insertBatch = async (logs: TAuditLogs[]) => {if (isClickHouseBatchEnabled) {await clickhouseClient!.insert({@@ -212,16 +202,6 @@ export const auditLogQueueServiceFactory = async ({}}- // A pre-rollout pod (before this stream format shipped) wrote the already-mapped- // audit-log row to the ingest stream, not the resolved DTO. Those legacy entries are- // flat (`actor`/`eventType` are strings, there is no nested `event` object)- type TLegacyAuditLogStreamEntry = Omit<TAuditLogs, "createdAt" | "expiresAt" | "updatedAt"> & {- createdAt: string;- expiresAt: string;- };- const isCurrentShape = (raw: Record<string, unknown>): boolean =>- typeof raw.event === "object" && raw.event !== null;-// Map a stream entry into a persistable audit log. org/plan/TTL/projectName were all// resolved at push time (see buildStreamEntry), so this is a pure shape transform with no DB// lookups. Entries that predate push-time resolution (in-flight during a rolling deploy) lack@@ -232,25 +212,6 @@ export const auditLogQueueServiceFactory = async ({return null;}- // Legacy flat entry: it is already in the persisted shape (mapped + normalized by the- // old pod), so only the timestamps need re-hydrating from their JSON ISO strings.- if (!isCurrentShape(raw as Record<string, unknown>)) {- const legacy = raw as TLegacyAuditLogStreamEntry;- if (!legacy.orgId || !legacy.expiresAt) {- logger.error(- `audit-log-queue: Skipping legacy entry missing resolved metadata [eventType=${legacy.eventType}] [orgId=${legacy.orgId}]`- );- return null;- }- const legacyCreatedAt = new Date(legacy.createdAt);- return {- ...legacy,- expiresAt: new Date(legacy.expiresAt),- createdAt: legacyCreatedAt,- updatedAt: legacyCreatedAt- };- }-const entry = raw as TAuditLogStreamEntry;if (!entry.orgId || !entry.expiresAt) {logger.error(diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.tsindex a6da7ffdab..9c75a80f17 100644--- a/backend/src/queue/queue-service.ts+++ b/backend/src/queue/queue-service.ts@@ -12,7 +12,6 @@ import {} from "bullmq";import { SecretEncryptionAlgo, SecretKeyEncoding } from "@app/db/schemas";-import { TCreateAuditLogDTO } from "@app/ee/services/audit-log/audit-log-types";import { TAuditLogStreamFlushJobData } from "@app/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-types";import { PamDiscoverySourceRunTrigger } from "@app/ee/services/pam-discovery/pam-discovery-enums";import {@@ -75,7 +74,6 @@ export const JOB_SCHEDULER_PREFIX = "jsv1";export enum QueueName {SecretReminder = "secret-reminder",- AuditLog = "audit-log",// TODO(akhilmhdh): This will get removed later. For now this is kept to stop the repeatable queueAuditLogPrune = "audit-log-prune",PkiAlertV2Event = "pki-alert-v2-event",@@ -120,7 +118,6 @@ export enum QueueName {export enum QueueJobs {SecretReminder = "secret-reminder-job",- AuditLog = "audit-log-job",// TODO(akhilmhdh): This will get removed later. For now this is kept to stop the repeatable queueAuditLogPrune = "audit-log-prune-job",DailyResourceCleanUp = "daily-resource-cleanup-job",@@ -234,10 +231,6 @@ export type TQueueJobTypes = {};name: QueueJobs.SecretReminder;};- [QueueName.AuditLog]: {- name: QueueJobs.AuditLog;- payload: TCreateAuditLogDTO;- };[QueueName.PkiAlertV2Event]: {name: QueueJobs.PkiAlertV2ProcessEvent;payload: {@@ -676,6 +669,9 @@ export const queueServiceFactory = (redisCfg: TRedisConfigKeys): TQueueServiceFa"queue-internal-recovery","queue-internal-reconciliation","secret-rotation",+ // Legacy per-log audit queue, replaced by the unified Redis ingest stream. The compatibility+ // shim that re-routed its jobs has been removed; obliterate any residue left in Redis.+ "audit-log",// Queues replaced by cronJobFactory (src/lib/cron/cron-job.ts)"daily-resource-cleanup","frequent-resource-cleanup",