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
define the decision requested at as null on the last attempt
adilsonebcb27098c4e
diff --git a/CLAUDE.md b/CLAUDE.mdindex fdb3b8f032..2bf4239fa8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -209,17 +209,18 @@ refusal (no row for the record id, bad or missing token, request not `waiting_apgets one neutral 403 while the reason goes to the log. An accepted callback only emits an outbox event, andonly when it wins `claimDecisionRead`: a conditional update of `decisionReadRequestedAt`, in the emit'stransaction, that one of any number of concurrent callbacks wins. A repeat while a read-back is still in-flight gets the same 200, emits nothing and is not counted; a claim older than `DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS`-(70 minutes, past the outbox's last retry) has expired, so a fresh notification after an earlier read-back-ran out of retries still starts one. `eventType` is the+flight gets the same 200, emits nothing and is not counted. The last read-back attempt clears+`decisionReadRequestedAt`, so a callback after the outbox gives up claims immediately. A claim whose worker+died before that write stays until it is older than `DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS`+(70 minutes), which is what lets a fresh notification start one then. `eventType` is thebody's event and `idempotencyKey` is the delegated request id plus the attempt count. The`delegated-approval-decision` consumer (`backend/src/services/delegated-approval-decision/`, a thin outboxadapter over `delegatedApprovalDecisionService.applyDecision` that, like dispatch, reads up to 10 differentrequests at once and one request's events serially) then reads the decision back through thepolicy's app connection: `TDelegatedApprovalProvider.fetchDecision` returns `pending` or a decision withthe permissions the provider holds, and the consumer answers `Retry` for `pending` (on the last attempt, `Failed`-with the request left open and a `statusReason` saying Infisical stopped checking and the callback has to be-sent again, which the claim TTL lets start a new read-back), compares the approved+with the request left open, `decisionReadRequestedAt` cleared, and a `statusReason` saying Infisical stopped+checking and the callback has to be sent again), compares the approvedpermissions with the ones it dispatched after both go through `normalizeDelegatedApprovalPermissions` (setcomparison: padding, order, duplicates and case never count as a change), and finalizes in one transactionthat locks the approval request, moves the delegated row `waiting_approval` → `approved` / `rejected`, anddiff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.tsindex 09eebc1f25..ea05536c65 100644--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-consumer.test.ts@@ -62,6 +62,7 @@ const APPROVAL_REQUEST_ID = "33333333-3333-3333-3333-333333333333";const ORG_ID = "22222222-2222-2222-2222-222222222222";const EXTERNAL_ID = "snow-1";const POLICY_NAME = "Production secrets";+const DECISION_READ_REQUESTED_AT = new Date("2026-10-27T15:00:00.000Z");const TX = { tx: true } as never;const PRIMARY = { primary: true } as never;const SERVICENOW_RECORD = { type: DelegatedApprovalPolicyType.ServiceNow, recordNumber: "INFAR1000000" };@@ -70,7 +71,8 @@ const waitingDelegatedRequest = {requestId: APPROVAL_REQUEST_ID,status: DelegatedApprovalRequestStatus.WaitingApproval,details: { statusReason: null, provider: SERVICENOW_RECORD } as TDelegatedApprovalRequestDetails,- providerRequestId: EXTERNAL_ID as string | null+ providerRequestId: EXTERNAL_ID as string | null,+ decisionReadRequestedAt: DECISION_READ_REQUESTED_AT as Date | null};type TDelegatedRow = typeof waitingDelegatedRequest;@@ -362,6 +364,7 @@ describe("delegatedApprovalDecisionConsumer", () => {}});expect(approval()?.status).toBe(ApprovalRequestStatus.Pending);+ expect(row()?.decisionReadRequestedAt).toEqual(DECISION_READ_REQUESTED_AT);expect(createAuditLog).not.toHaveBeenCalled();});@@ -518,6 +521,7 @@ describe("delegatedApprovalDecisionConsumer", () => {}});expect(approval()?.status).toBe(ApprovalRequestStatus.Pending);+ expect(row()?.decisionReadRequestedAt).toBeNull();expect(createAuditLog).not.toHaveBeenCalled();});@@ -532,6 +536,7 @@ describe("delegatedApprovalDecisionConsumer", () => {expect(row()?.details.statusReason).toBe(`ServiceNow could not be reached. ${DELEGATED_APPROVAL_DECISION_STOPPED_HINT}`);+ expect(row()?.decisionReadRequestedAt).toBeNull();expect(approval()?.status).toBe(ApprovalRequestStatus.Pending);});@@ -554,6 +559,7 @@ describe("delegatedApprovalDecisionConsumer", () => {expect(result).toEqual({ id: "1", status, error: "The grant could not be written." });expect(row()?.status).toBe(DelegatedApprovalRequestStatus.WaitingApproval);expect(row()?.details.statusReason).toBe(statusReason);+ expect(row()?.decisionReadRequestedAt).toEqual(isFinalAttempt ? null : DECISION_READ_REQUESTED_AT);expect(approval()?.status).toBe(ApprovalRequestStatus.Pending);expect(createAuditLog).not.toHaveBeenCalled();}diff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.tsindex 0a73787822..85e3169c08 100644--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts@@ -114,7 +114,10 @@ export const delegatedApprovalDecisionServiceFactory = ({try {await delegatedApprovalRequestDAL.updateWithDetails({ id: delegatedRequestId, status: DelegatedApprovalRequestStatus.WaitingApproval },- { details: { statusReason: toDelegatedApprovalStatusReason(`${reason} ${hint}`) } }+ {+ ...(isFinalAttempt ? { decisionReadRequestedAt: null } : {}),+ details: { statusReason: toDelegatedApprovalStatusReason(`${reason} ${hint}`) }+ });} catch (error) {logger.error(