Skip to content

Commit aa6bcad

Browse files
committed
Fix detect 400: JSON-clean result (strip undefined for Schema.Unknown encoder)
The HttpApi/MCP Schema.Unknown response encoder rejects explicit `undefined` nested values as non-JSON. Domains whose auth/mcp objects had any undefined optional field (e.g. sentry, modelcontextprotocol.io: no registration_endpoint) returned 400. JSON-clean the detect result at the runDetect boundary.
1 parent 639dc61 commit aa6bcad

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

worker/operations.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export const DETECT_DESCRIPTION =
3030
"server-card, agent-card, agent-skills, llms.txt) plus live capability " +
3131
"detection — MCP self-onboarding (DCR/CIMD) and the live OpenAPI schema.";
3232

33-
/** The detect handler, shared by REST and MCP. */
33+
/** The detect handler, shared by REST and MCP. JSON-cleans the result so the
34+
* Schema.Unknown response encoder never sees an explicit `undefined` (not a
35+
* valid JSON value). */
3436
export const runDetect = (domain: string): Effect.Effect<typeof DetectionResult.Type> =>
35-
Effect.promise(() => detect(domain.trim().toLowerCase()) as Promise<typeof DetectionResult.Type>);
37+
Effect.promise(async () => {
38+
const r = await detect(domain.trim().toLowerCase());
39+
return JSON.parse(JSON.stringify(r)) as typeof DetectionResult.Type;
40+
});

0 commit comments

Comments
 (0)