Skip to content

Commit

Permalink
fix: make redaction work by using From explicitly (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Nov 17, 2023
1 parent da27a47 commit f2eabd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions crates/rattler_networking/src/redaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use itertools::Itertools;
use url::Url;

/// A default string to use for redaction.
pub const DEFAULT_REDACTION_STR: &str = "xxxxxxxx";
pub const DEFAULT_REDACTION_STR: &str = "********";

/// Anaconda channels are not always publicly available. This function checks if a URL contains a
/// secret by identifying whether it contains certain patterns. If it does, the function returns a
Expand Down Expand Up @@ -68,7 +68,7 @@ mod test {
),
Some(
Url::from_str(
"https://conda.anaconda.org/t/xxxxxxxx/conda-forge/noarch/repodata.json"
&format!("https://conda.anaconda.org/t/{DEFAULT_REDACTION_STR}/conda-forge/noarch/repodata.json")
)
.unwrap()
)
Expand Down
12 changes: 6 additions & 6 deletions crates/rattler_repodata_gateway/src/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl From<reqwest::Error> for FetchRepoDataError {
}

impl From<reqwest::Error> for RepoDataNotFoundError {
fn from(value: reqwest::Error) -> Self {
Self::HttpError(redact_known_secrets_from_error(value))
fn from(err: reqwest::Error) -> Self {
Self::HttpError(redact_known_secrets_from_error(err))
}
}

Expand Down Expand Up @@ -491,13 +491,13 @@ pub async fn fetch_repo_data(
// Send the request and wait for a reply
let response = match request_builder.headers(headers).send().await {
Ok(response) if response.status() == StatusCode::NOT_FOUND => {
return Err(FetchRepoDataError::NotFound(
RepoDataNotFoundError::HttpError(response.error_for_status().unwrap_err()),
));
return Err(FetchRepoDataError::NotFound(RepoDataNotFoundError::from(
response.error_for_status().unwrap_err(),
)));
}
Ok(response) => response.error_for_status()?,
Err(e) => {
return Err(FetchRepoDataError::HttpError(e));
return Err(FetchRepoDataError::from(e));
}
};

Expand Down

0 comments on commit f2eabd5

Please sign in to comment.