feat(sdk): export item unmarshalers, attribute client errors to upstream host#364
Merged
Conversation
…eam host - Export v1.UnmarshalItem/UnmarshalItems so consumers can decode items without hand-mirroring the type-tag dispatch (new item types now fail loudly instead of being silently dropped downstream). - Give ItemCompletedEvent an UnmarshalJSON: its Item field is an interface, so the event was previously undecodable with plain encoding/json despite client.Event docs saying to decode into it. - APIError carries the upstream Host and renders it in Error() instead of the fixed "relay client:" prefix — a 401 from a directly-dialed vendor host no longer reads as a relay failure. - Document catalog.Binding.Name's non-empty guarantee.
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.
SDK consumer feedback fixes, all in the
sdk/module:v1.UnmarshalItem/v1.UnmarshalItems. Consumers persisting or re-parsing canonical items had to hand-mirror the type-tag dispatch; with the exported unmarshaler a new item type fails loudly instead of being silently dropped by a stale mirror.ItemCompletedEventgets anUnmarshalJSON. ItsItemfield is an interface, so the event was undecodable with plainencoding/jsoneven thoughclient.Eventdocs say to decode into the matching v1 struct.APIErrornow carriesHostand renders it inError()(api.anthropic.com: 401 ...) instead of the fixedrelay client:prefix — a 4xx from a directly-dialed vendor host (For(ref)mode) no longer reads as a relay failure. Applies to both HTTP and WS paths (sharedparseAPIError).catalog.Binding.Nameis guaranteed non-empty (generator falls back to the snapshot slug), so consumers don't need their own fallback.