From c4b6921314c10d8747078b729812e61d94af43fb Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 9 Jul 2023 20:39:18 +1000 Subject: [PATCH] fix `binstalk_downloader::GhApiClient` json deser error (#1193) When installing `cargo-expand` v1.0.59, I got an error message: ``` Failed to parse http response body as Json: invalid type: null, expected a string at line 1 column 90 ``` This is because `GraphQLPageInfo::end_cursor` can actually be `null`, so I change its type to `Option`. Signed-off-by: Jiahao XU --- .../src/gh_api_client/request.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/binstalk-downloader/src/gh_api_client/request.rs b/crates/binstalk-downloader/src/gh_api_client/request.rs index 2289566c..59e0d140 100644 --- a/crates/binstalk-downloader/src/gh_api_client/request.rs +++ b/crates/binstalk-downloader/src/gh_api_client/request.rs @@ -289,7 +289,7 @@ struct GraphQLReleaseAssets { #[derive(Deserialize)] struct GraphQLPageInfo { #[serde(rename = "endCursor")] - end_cursor: CompactString, + end_cursor: Option, #[serde(rename = "hasNextPage")] has_next_page: bool, } @@ -376,11 +376,14 @@ query {{ if let Some(assets) = assets { artifacts.assets.extend(assets.nodes); - let page_info = assets.page_info; - if !page_info.has_next_page { - break Ok(FetchReleaseRet::Artifacts(artifacts)); - } else { - cond = FilterCondition::After(page_info.end_cursor); + match assets.page_info { + GraphQLPageInfo { + end_cursor: Some(end_cursor), + has_next_page: true, + } => { + cond = FilterCondition::After(end_cursor); + } + _ => break Ok(FetchReleaseRet::Artifacts(artifacts)), } } else { break Ok(FetchReleaseRet::ReleaseNotFound);