From c2d244a5c9404d7ea8424ab0d9abc55e804fea2a Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Mon, 29 Dec 2025 23:25:40 +1000 Subject: [PATCH] fix: use dynamic import for Zod v4 JSON schema conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static import from 'zod@4/json-schema' was failing and crashing executor. Use dynamic import inside the schema extraction logic instead. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- apps/railway-executor/server.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/railway-executor/server.ts b/apps/railway-executor/server.ts index c911952..3b87011 100644 --- a/apps/railway-executor/server.ts +++ b/apps/railway-executor/server.ts @@ -5,8 +5,6 @@ // Import zod-to-json-schema for Zod v3 support import { zodToJsonSchema } from 'https://esm.sh/zod-to-json-schema@3.25.0'; -// Import Zod v4's JSON Schema converter (for packages using Zod v4) -import { toJSONSchema as zodV4ToJsonSchema } from 'https://esm.sh/zod@4/json-schema'; // Cache TTL: 2 minutes const CACHE_TTL_MS = 2 * 60 * 1000; @@ -410,12 +408,16 @@ async function loadAndDescribe(req: Request): Promise { // Strategy 3: Try Zod v4 schema (detect via _zod property - new in Zod v4) if (!rawJsonSchema && toolModule.inputSchema._zod) { - console.log( - `📋 Detected Zod v4 schema, converting with Zod v4 toJSONSchema for ${cacheKey}` - ); + console.log(`📋 Detected Zod v4 schema for ${cacheKey}`); try { - rawJsonSchema = zodV4ToJsonSchema(toolModule.inputSchema); - console.log(`✅ Successfully converted Zod v4 schema for ${cacheKey}`); + // Dynamically import Zod v4's toJSONSchema function + const zodJsonSchema = await import('https://esm.sh/zod@4.0.0/json-schema'); + if (zodJsonSchema.toJSONSchema) { + rawJsonSchema = zodJsonSchema.toJSONSchema(toolModule.inputSchema); + console.log(`✅ Successfully converted Zod v4 schema for ${cacheKey}`); + } else { + console.warn(`⚠️ Zod v4 toJSONSchema function not found in module`); + } } catch (error) { console.warn(`⚠️ Zod v4 toJSONSchema conversion failed for ${cacheKey}:`, error); }