feat(transport): add constructors for non-exhaustive error types#806
Open
wpfleger96 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat(transport): add constructors for non-exhaustive error types#806wpfleger96 wants to merge 1 commit intomodelcontextprotocol:mainfrom
wpfleger96 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
AuthRequiredError, InsufficientScopeError, and DynamicTransportError were marked #[non_exhaustive] in modelcontextprotocol#715/modelcontextprotocol#768 but don't have constructors usable by external crates. Add new() for the error types and from_parts() for DynamicTransportError (the existing new() requires a Transport type parameter, making it unusable for test fixtures). Fixes modelcontextprotocol#805
76d202c to
952bb5f
Compare
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.
AuthRequiredError,InsufficientScopeError, andDynamicTransportErrorwere marked#[non_exhaustive]in #715 / #768 but don't have constructors usable by external crates, making it impossible to construct these types in tests or other downstream code without resorting to serde roundtrips.This follows the same pattern as
StoredCredentialsin #778 —#[non_exhaustive]structs need constructors to be usable outside the crate.AuthRequiredError::new(www_authenticate_header)andInsufficientScopeError::new(www_authenticate_header, required_scope)DynamicTransportError::from_parts(transport_name, transport_type_id, error)— the existing::new<T: Transport>()requires a concrete transport type, making it unusable for test fixtures that need fake transport names/type IDsFixes #805