fix(google-discovery): JSON-safe Option encoding for persisted bindings#706
Open
aryasaatvik wants to merge 2 commits intoRhysSullivan:mainfrom
Open
fix(google-discovery): JSON-safe Option encoding for persisted bindings#706aryasaatvik wants to merge 2 commits intoRhysSullivan:mainfrom
aryasaatvik wants to merge 2 commits intoRhysSullivan:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools.listreturns 500 for any persisted google-discovery source:In Effect v4,
Schema.Option(...)is a self-declaration (Type == Encoded == Option). The v4 migration (edd904c8) swapped v3'soptionalWith({ as: "Option" })for it, so encoded values still hold realOptioninstances. Thebindingcolumn is JSON-mode, so Drizzle stringifies —Option.toJSONemits{_id, _tag, value}, which the decoder then rejects on read.Replaced with
Schema.OptionFromOptional(...)(the v4 equivalent of v3'soptionalWith({as:"Option"}), already used by openapi). Runtime type staysOption<...>, encoded form is JSON-safe.Migration
Existing rows persisted with the broken shape still fail to decode. Clear them so bindings re-derive:
DELETE FROM google_discovery_binding WHERE source_id = '<id>';and refresh.Test plan
vitest run packages/plugins/google-discovery(11/11)tools.listreturns 200