From 1f7afcebe31d8e3a79cf871ba5d3c7ac2bc46d3c Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Thu, 19 Mar 2026 11:22:04 +0100 Subject: [PATCH] :sparkles: Apply throwValidationErrors flag during MCP code executions #8682 --- .../src/task-handlers/ExecuteCodeTaskHandler.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mcp/packages/plugin/src/task-handlers/ExecuteCodeTaskHandler.ts b/mcp/packages/plugin/src/task-handlers/ExecuteCodeTaskHandler.ts index 213333bab9..85ed5a32d1 100644 --- a/mcp/packages/plugin/src/task-handlers/ExecuteCodeTaskHandler.ts +++ b/mcp/packages/plugin/src/task-handlers/ExecuteCodeTaskHandler.ts @@ -195,16 +195,19 @@ export class ExecuteCodeTaskHandler extends TaskHandler { const context = this.context; const code = task.params.code; - // set the penpot.flags.naturalChildOrdering to true during code execution. - // NOTE: This significantly simplifies API usage (see ) - // TODO: Remove ts-ignore once Penpot types have been updated - let originalNaturalChildOrdering: any; + // set the flags naturalChildOrdering and throwValidationErrors to true during code execution. + // TODO: Remove all ts-ignore once Penpot types have been updated + let originalNaturalChildOrdering: any, originalThrowValidationErrors: any; // @ts-ignore if (penpot.flags) { // @ts-ignore originalNaturalChildOrdering = penpot.flags.naturalChildOrdering; // @ts-ignore penpot.flags.naturalChildOrdering = true; + // @ts-ignore + originalThrowValidationErrors = penpot.flags.throwValidationErrors; + // @ts-ignore + penpot.flags.throwValidationErrors = true; } else { // TODO: This can be removed once `flags` has been merged to PROD throw new Error( @@ -224,9 +227,11 @@ export class ExecuteCodeTaskHandler extends TaskHandler { return fn(...Object.values(ctx)); })(context); } finally { - // restore the original value of penpot.flags.naturalChildOrdering + // restore the original value of the flags // @ts-ignore penpot.flags.naturalChildOrdering = originalNaturalChildOrdering; + // @ts-ignore + penpot.flags.throwValidationErrors = originalThrowValidationErrors; } console.log("Code execution result:", result);