From 6594b13831f129d6cd2e7ee786234233f6f40267 Mon Sep 17 00:00:00 2001 From: Saatvik Arya Date: Fri, 8 May 2026 11:06:08 +0530 Subject: [PATCH] fix(google-discovery): JSON-safe Option encoding for persisted bindings Schema.Option in Effect v4 is a self-declaration (Type == Encoded == Option), so encoded values still hold real Option instances. When the binding column (JSON-mode text) gets JSON.stringify'd, Option.toJSON emits {_id, _tag, value} -- which decode then rejects on read with "Expected Option, got {_id:Option,_tag:Some,value:...}", failing tools.list with a 500. Replace Schema.Option(...) with Schema.OptionFromOptional(...) -- the v4 equivalent of v3's optionalWith({ as: "Option" }) -- so encoded form is a JSON-safe absent/present field while the runtime type stays Option<...>. Matches the pattern already used by openapi. Existing rows persisted with the broken shape need to be cleared (delete + re-add the source, or DELETE FROM google_discovery_binding WHERE source_id = '...') so bindings re-derive with the corrected encoding. --- packages/plugins/google-discovery/src/sdk/types.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/plugins/google-discovery/src/sdk/types.ts b/packages/plugins/google-discovery/src/sdk/types.ts index b2f3a9830..468eef607 100644 --- a/packages/plugins/google-discovery/src/sdk/types.ts +++ b/packages/plugins/google-discovery/src/sdk/types.ts @@ -22,8 +22,8 @@ export class GoogleDiscoveryParameter extends Schema.Class( @@ -39,22 +39,22 @@ export class GoogleDiscoveryManifestMethod extends Schema.Class( "GoogleDiscoveryManifest", )({ - title: Schema.Option(Schema.String), + title: Schema.OptionFromOptional(Schema.String), service: Schema.String, version: Schema.String, rootUrl: Schema.String, servicePath: Schema.String, - oauthScopes: Schema.Option(Schema.Record(Schema.String, Schema.String)), + oauthScopes: Schema.OptionFromOptional(Schema.Record(Schema.String, Schema.String)), schemaDefinitions: Schema.Record(Schema.String, Schema.Unknown), methods: Schema.Array(GoogleDiscoveryManifestMethod), }) {}