From c2e5cfb4fe4ae0b0a2354dd980b3bcacce5ca180 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 5 Oct 2023 15:41:49 -0700 Subject: [PATCH] Fix github_releases with invalid URIs --- src/handlers/github_releases.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/handlers/github_releases.rs b/src/handlers/github_releases.rs index 0df9b872..d9ecbffa 100644 --- a/src/handlers/github_releases.rs +++ b/src/handlers/github_releases.rs @@ -40,7 +40,7 @@ pub(super) async fn handle( log::debug!("loading the git tags"); let tags = load_paginated( ctx, - &format!("repos/{}/git/matching-refs/tags", event.repo().full_name), + &format!("/repos/{}/git/matching-refs/tags", event.repo().full_name), |git_ref: &GitRef| { git_ref .name @@ -54,7 +54,7 @@ pub(super) async fn handle( log::debug!("loading the existing releases"); let releases = load_paginated( ctx, - &format!("repos/{}/releases", event.repo().full_name), + &format!("/repos/{}/releases", event.repo().full_name), |release: &Release| release.tag_name.clone(), ) .await?; @@ -85,7 +85,7 @@ pub(super) async fn handle( let e: octocrab::Result = ctx .octocrab .post( - format!("repos/{}/releases", event.repo().full_name), + format!("/repos/{}/releases", event.repo().full_name), Some(&serde_json::json!({ "tag_name": tag, "name": expected_name, @@ -141,7 +141,11 @@ where R: Eq + PartialEq + std::hash::Hash, F: Fn(&T) -> R, { - let mut current_page: Page = ctx.octocrab.get::, _, ()>(url, None).await?; + let mut current_page: Page = ctx + .octocrab + .get::, _, ()>(url, None) + .await + .with_context(|| format!("failed to load {url}"))?; let mut items = current_page .take_items() @@ -149,7 +153,12 @@ where .map(|val| (key(&val), val)) .collect::>(); - while let Some(mut new_page) = ctx.octocrab.get_page::(¤t_page.next).await? { + while let Some(mut new_page) = ctx + .octocrab + .get_page::(¤t_page.next) + .await + .with_context(|| format!("failed to load next page {:?}", current_page.next))? + { items.extend( new_page .take_items()