Skip to content

FuelClient::new removes potentially critical path information #3176

@HenryMBaldwin

Description

@HenryMBaldwin

FuelClient::new used the FromStr implementation of FuelClient. This implementation is curious:

impl FromStr for FuelClient {
    type Err = anyhow::Error;

    fn from_str(str: &str) -> Result<Self, Self::Err> {
        let mut raw_url = str.to_string();
        if !raw_url.starts_with("http") {
            raw_url = format!("http://{raw_url}");
        }

        let mut url = reqwest::Url::parse(&raw_url)
            .map_err(anyhow::Error::msg)
            .with_context(|| format!("Invalid fuel-core URL: {str}"))?;
        url.set_path("/v1/graphql");

        ...
    }
}

Do you see it? url.set_path wipes out any path information on the url. Some node providers (quiknode) use the path to store auth information. Of course there is also the option to use headers for quiknode, but there is not an implementation for that here either.

I don't really understand why babysitting the url here is necessary, and it seems to me like this cleaning should just be removed and users be responsible for using correct url paths, however either way this should be rethought.

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