Skip to content

AuthRequiredError and DynamicTransportError need constructors for external crates #805

@wpfleger96

Description

@wpfleger96

AuthRequiredError and DynamicTransportError were marked #[non_exhaustive] in #715 / #768, but neither has a constructor usable by external crates. Same situation as StoredCredentials (#777, fixed in #778).

AuthRequiredError has no constructor at all. External crates testing auth error handling paths (e.g. verifying that should_attempt_oauth_fallback correctly detects auth challenges) can't construct test fixtures without a serde roundtrip.

DynamicTransportError has ::new<T: Transport<R>>(), but it requires a real Transport impl as a type parameter. This makes it unusable for test fixtures that need a fake transport name and type ID.

We ran into both of these in block/goose after bumping to rmcp 1.4.0 (the same upgrade that surfaced the StoredCredentials issue).

Suggested fixes:

impl AuthRequiredError {
    pub fn new(www_authenticate_header: String) -> Self {
        Self { www_authenticate_header }
    }
}

impl DynamicTransportError {
    pub fn from_parts(
        transport_name: impl Into<Cow<'static, str>>,
        transport_type_id: std::any::TypeId,
        error: Box<dyn std::error::Error + Send + Sync>,
    ) -> Self {
        Self { transport_name: transport_name.into(), transport_type_id, error }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions