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
refactor(audit-log): enhance dropped claims handling to include provider information
Victor Hugo dos Santosce074307ca46
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.tsindex 04156701f3..8ed74ff254 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@@ -167,7 +167,7 @@ export const auditLogStreamOutboxDALFactory = (db: TDbClient) => {const recoverStaleClaims = async (thresholdMs: number,maxAttempts: number- ): Promise<{ retried: number; dropped: { streamId: string; orgId: string }[] }> => {+ ): Promise<{ retried: number; dropped: { streamId: string; orgId: string; provider: string | null }[] }> => {try {return await db.transaction(async (tx) => {const staleRows = await tx(TableName.AuditLogStreamOutbox)@@ -203,18 +203,27 @@ export const auditLogStreamOutboxDALFactory = (db: TDbClient) => {});}- if (exhausted.length > 0) {- await tx(TableName.AuditLogStreamOutbox)- .whereIn(- "id",- exhausted.map((row) => row.id)- )- .del();- }+ if (exhausted.length === 0) return { retried: retriable.length, dropped: [] };++ await tx(TableName.AuditLogStreamOutbox)+ .whereIn(+ "id",+ exhausted.map((row) => row.id)+ )+ .del();++ const streams = await tx(TableName.AuditLogStream)+ .whereIn("id", [...new Set(exhausted.map((row) => row.streamId))])+ .select<{ id: string; provider: string }[]>("id", "provider");+ const providerByStreamId = new Map(streams.map((stream) => [stream.id, stream.provider]));return {retried: retriable.length,- dropped: exhausted.map((row) => ({ streamId: row.streamId, orgId: row.orgId }))+ dropped: exhausted.map((row) => ({+ streamId: row.streamId,+ orgId: row.orgId,+ provider: providerByStreamId.get(row.streamId) ?? null+ }))};});} catch (error) {diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.tsindex 03854336d9..6d63a03d54 100644--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts@@ -379,15 +379,19 @@ export const auditLogStreamOutboxServiceFactory = ({}if (dropped.length > 0) {// Stale claims that used up their attempts are dropped (no DLQ); count them alongside- // delivery-path exhaustions, keyed by stream. No provider attribute here — the row doesn't carry- // it and the sweep isn't tied to a specific delivery attempt.- const droppedCountByStream = new Map<string, number>();- for (const { streamId } of dropped) {- droppedCountByStream.set(streamId, (droppedCountByStream.get(streamId) ?? 0) + 1);+ // delivery-path exhaustions so both losses show up on the same counter, keyed the same way.+ // The provider is resolved by the DAL and is null only when the stream itself is already gone,+ // which is one of the reasons a claim goes stale.+ const droppedCountByStream = new Map<string, { provider: string | null; count: number }>();+ for (const { streamId, provider } of dropped) {+ const existing = droppedCountByStream.get(streamId);+ if (existing) existing.count += 1;+ else droppedCountByStream.set(streamId, { provider, count: 1 });}- for (const [streamId, count] of droppedCountByStream) {+ for (const [streamId, { provider, count }] of droppedCountByStream) {auditLogStreamDeliveryExhaustedCounter.add(count, {- "audit_log_stream.id": streamId+ "audit_log_stream.id": streamId,+ ...(provider && { "audit_log_stream.provider": provider })});}}