Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 404 during pagination for GitHub Enterprise #213

Open
svend opened this issue Mar 7, 2019 · 2 comments
Open

Getting 404 during pagination for GitHub Enterprise #213

svend opened this issue Mar 7, 2019 · 2 comments
Labels

Comments

@svend
Copy link

svend commented Mar 7, 2019

🐛 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

@dwijnand
Copy link
Contributor

dwijnand commented Mar 8, 2019

Interesting! What is the value of the LINK header in the first request's response?

@svend
Copy link
Author

svend commented Mar 8, 2019

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"

@softprops softprops added the bug label Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants