softprops / hubcaps

a rust interface for github
http://docs.rs/hubcaps
MIT License
279 stars 68 forks source link

Panic (index out of bounds) while listing a PR with a lot of files #300

Open piegamesde opened 3 years ago

piegamesde commented 3 years ago

πŸ› Bug description

thread 'main' panicked at 'removal index (is 0) should be < len (is 0)'

thread 'main' panicked at 'removal index (is 0) should be < len (is 0)', library/alloc/src/vec/mod.rs:1385:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: alloc::vec::Vec<T,A>::remove::assert_failed
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:1385:13
   3: alloc::vec::Vec<T,A>::remove
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/vec/mod.rs:1390:13
   4: hubcaps::unfold::{{closure}}::{{closure}}::{{closure}}
             at $CARGO_HOME/git/checkouts/hubcaps-5f6b464d07ae08cc/d750741/src/lib.rs:1120:48
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/future/mod.rs:80:19
   6: <F as futures_core::future::TryFuture>::try_poll
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.15/src/future.rs:82:9
   7: <futures_util::stream::try_stream::try_unfold::TryUnfold<T,F,Fut> as futures_core::stream::Stream>::poll_next
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.15/src/stream/try_stream/try_unfold.rs:108:35
   8: <S as futures_core::stream::TryStream>::try_poll_next
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.15/src/stream.rs:196:9
   9: <futures_util::future::try_future::try_flatten::TryFlatten<Fut,<Fut as futures_core::future::TryFuture>::Ok> as futures_core::stream::Stream>::poll_next
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.15/src/future/try_future/try_flatten.rs:98:41
  10: <futures_util::future::try_future::TryFlattenStream<Fut> as futures_core::stream::Stream>::poll_next
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.15/src/lib.rs:104:13
  11: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.15/src/stream.rs:120:9
  12: futures_util::stream::stream::StreamExt::poll_next_unpin
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.15/src/stream/stream/mod.rs:1416:9
  13: <futures_util::stream::stream::next::Next<St> as core::future::future::Future>::poll
             at $CARGO_HOME/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.15/src/stream/stream/next.rs:32:9
  14: codeowner_rs::main::{{closure}}
             at ./src/main.rs:55:32

πŸ€” Expected Behavior

The application never panics

πŸ‘Ÿ Steps to reproduce

Try to read https://github.com/NixOS/nixpkgs/pull/119896:

let github = Github::new(todo!(), todo!(),)?;
let repo = github.repo("NixOS", "nixpkgs");
let pulls = repo.pulls();
let pr = pulls.get(119896);
let mut iter = pr.iter_files();
while let Some(diff) = iter.next().await.transpose()? {
   println!("{}", diff.filename);
}

🌍 Your environment

hubcaps version: 2 commits ahead of master.