diff --git a/lib/src/component/error.rs b/lib/src/component/error.rs index b1b47a06..dd6e3263 100644 --- a/lib/src/component/error.rs +++ b/lib/src/component/error.rs @@ -175,6 +175,7 @@ impl From for types::Error { Error::DictionaryError(e) => e.into(), Error::ObjectStoreError(e) => e.into(), Error::SecretStoreError(e) => e.into(), + Error::InvalidBackendUrl => types::Error::HttpInvalid, // All other hostcall errors map to a generic `ERROR` value. Error::AbiVersionMismatch | Error::BackendUrl(_) diff --git a/lib/src/error.rs b/lib/src/error.rs index ad0b49c7..6237734b 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -119,6 +119,9 @@ pub enum Error { #[error(transparent)] HttpError(#[from] http::Error), + #[error("Invalid Url")] + InvalidBackendUrl, + #[error("Object Store '{0}' does not exist")] UnknownObjectStore(String), @@ -184,6 +187,7 @@ impl Error { Error::ObjectStoreError(e) => e.into(), Error::SecretStoreError(e) => e.into(), Error::Again => FastlyStatus::Again, + Error::InvalidBackendUrl => FastlyStatus::Httpinvalid, // All other hostcall errors map to a generic `ERROR` value. Error::AbiVersionMismatch | Error::BackendUrl(_) diff --git a/lib/src/wiggle_abi/req_impl.rs b/lib/src/wiggle_abi/req_impl.rs index 8bd837a4..db7259f4 100644 --- a/lib/src/wiggle_abi/req_impl.rs +++ b/lib/src/wiggle_abi/req_impl.rs @@ -411,12 +411,18 @@ impl FastlyHttpReq for Session { let grpc = backend_info_mask.contains(BackendConfigOptions::GRPC); + let uri = match Uri::builder() + .scheme(scheme) + .authority(origin_name) + .path_and_query("/") + .build() + { + Ok(uri) => uri, + Err(_) => return Err(Error::InvalidBackendUrl), + }; + let new_backend = Backend { - uri: Uri::builder() - .scheme(scheme) - .authority(origin_name) - .path_and_query("/") - .build()?, + uri: uri, override_host, cert_host, use_sni,