From 8752cd97515b1c0c628577cfe0c590216797f599 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sun, 14 Dec 2025 22:02:22 +0100 Subject: [PATCH] Fix service discovery bug: Use parsed.serviceName instead of parsed.service Bug: getService() was accessing parsed.service (undefined) instead of parsed.serviceName, causing D1_TYPE_ERROR in service discovery. This affected both random discovery (line 263) and paginated discovery (line 218) when clients requested services without specifying username. The parseServiceFqn() function returns { serviceName, version, username }, not { service, version, username }. Fixes: D1_TYPE_ERROR: Type 'undefined' not supported for value 'undefined' when discovering services like 'test-chat:1.0.0' (without @username) --- src/rpc.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc.ts b/src/rpc.ts index 78f9cf1..60f707f 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -215,7 +215,7 @@ const handlers: Record = { const pageLimit = Math.min(Math.max(1, limit), MAX_PAGE_SIZE); const pageOffset = Math.max(0, offset || 0); - const allServices = await storage.discoverServices(parsed.service, parsed.version, 1000, 0); + const allServices = await storage.discoverServices(parsed.serviceName, parsed.version, 1000, 0); const compatibleServices = filterCompatibleServices(allServices); // Get unique services per username with available offers @@ -260,7 +260,7 @@ const handlers: Record = { } // Mode 3: Random discovery without username - const randomService = await storage.getRandomService(parsed.service, parsed.version); + const randomService = await storage.getRandomService(parsed.serviceName, parsed.version); if (!randomService) { throw new Error('No services found');