hubcaps
hubcaps copied to clipboard
Getting 404 during pagination for GitHub Enterprise
🐛 Bug description
I'm trying to get a list of repositories for an organization using .iter() for a GitHub Enterprise instance. The API endpoint for the Enterprise instance is https://<GITHUB_HOST>/api/v3. I get the first 30 results, then a 404 error.
🤔 Expected Behavior
I expect to get all the repositories.
👟 Steps to reproduce
Here is sample code that produces the error for me.
use std::env;
use futures::Stream;
use hubcaps::{Github, Result};
use tokio::runtime::Runtime;
fn main() -> Result<()> {
let github_endpoint = env::var("GITHUB_ENDPOINT").unwrap();
let github_org = env::var("GITHUB_ORG").unwrap();
let mut rt = Runtime::new()?;
let github = Github::host(
github_endpoint,
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
None,
);
rt.block_on(
github
.org_repos(github_org)
.iter(&Default::default())
.for_each(move |repo| {
println!("{}", repo.name);
Ok(())
}),
)?;
Ok(())
}
$ GITHUB_ENDPOINT=http://<GITHUB_HOST>/api/v3 GITHUB_ORG=example cargo run
...
Error: Error(Fault { code: 404, error: ClientError { message: "Not Found", errors: None } }, State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })
I sent the requests through mitmproxy to see what was going on, and the API endpoint is getting duplicated on the second request.
[::1]:57393: GET https://<GITHUB_HOST>/api/v3/orgs/example/repos
<< 200 OK 173.38k
[::1]:57393: GET https://<GITHUB_HOST>/api/v3/api/v3/organizations/279/repos?page=2
<< 404 Not Found 93b
[::1]:57393: clientdisconnect
Note the /api/v3/api/v3 in the second GET.
🌍 Your environment
hubcaps version: 0.5.0
Interesting! What is the value of the LINK header in the first request's response?
Here is the request and Link header:
GET https://<GITHUB_HOST>/api/v3/orgs/example/repos
Link: <https://<GITHUB_HOST>/api/v3/organizations/279/repos?page=2>; rel="next", <https://<GITHUB_HOST>/api/v3/organizations/279/repos?page=7>; rel="last"