From 292e9ba2800786cbf69c581bfc8a78baa24efd0b Mon Sep 17 00:00:00 2001 From: alban bertolini Date: Fri, 24 Jul 2026 15:23:32 +0200 Subject: [PATCH] feat(workflow-executor): accept the approval request id on a native trigger submit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A frontend-native (manual / AI-assisted) trigger-action files the approval request itself; accept its id on the pending-data patch so it is persisted in userConfirmation and the run panel can deep-link to it — parity with the Full-AI path, whose approval id already flows through the outcome. Strict, optional. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/http/pending-data-validators.ts | 6 +++++ .../test/http/pending-data-validators.test.ts | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/workflow-executor/src/http/pending-data-validators.ts b/packages/workflow-executor/src/http/pending-data-validators.ts index 4e2d6aabe1..ea00602e63 100644 --- a/packages/workflow-executor/src/http/pending-data-validators.ts +++ b/packages/workflow-executor/src/http/pending-data-validators.ts @@ -26,6 +26,12 @@ const triggerActionPatchSchema = z // Whether the native submit actually executed the action, or only created an approval request // (non-blocking): downstream AI steps must be told an awaiting-approval action did NOT run. submissionOutcome: z.enum(['executed', 'pending-approval']).optional(), + // The approval request the native submit filed, when submissionOutcome is 'pending-approval'. + // Persisted so the run panel can deep-link to it (parity with the Full-AI path). + approvalRequest: z + .object({ id: z.string().min(1) }) + .strict() + .optional(), }) .strict(); diff --git a/packages/workflow-executor/test/http/pending-data-validators.test.ts b/packages/workflow-executor/test/http/pending-data-validators.test.ts index 4e09b0c503..5ca7fa6eba 100644 --- a/packages/workflow-executor/test/http/pending-data-validators.test.ts +++ b/packages/workflow-executor/test/http/pending-data-validators.test.ts @@ -125,6 +125,30 @@ describe('patchBodySchemas', () => { expect(parsed).toEqual({ userConfirmed: false }); }); + it('accepts a pending-approval submit carrying the approval request id', () => { + const parsed = schema.parse({ + userConfirmed: true, + submissionOutcome: 'pending-approval', + approvalRequest: { id: 'appr-1' }, + }); + + expect(parsed).toEqual({ + userConfirmed: true, + submissionOutcome: 'pending-approval', + approvalRequest: { id: 'appr-1' }, + }); + }); + + it('rejects an approvalRequest with an empty id', () => { + expect(() => schema.parse({ userConfirmed: true, approvalRequest: { id: '' } })).toThrow(); + }); + + it('rejects extra keys inside approvalRequest (strict)', () => { + expect(() => + schema.parse({ userConfirmed: true, approvalRequest: { id: 'a', extra: 'leak' } }), + ).toThrow(); + }); + it('rejects unknown fields (strict schema)', () => { expect(() => schema.parse({ userConfirmed: true, actionResult: {}, extra: 'leak' }),