Skip to content

Commit d4c82e7

Browse files
committed
fix: don't assume that credential providers always return credentials or error during handshake.
The type-system allows this even though when getting credentials this should never happen and won't in the default implementation. However, users can of course return nothing and provide no error which is when we have to create one, instead of panicking.
1 parent 87f5621 commit d4c82e7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

gix-protocol/src/handshake/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
progress.set_name("authentication");
4747
let credentials::protocol::Outcome { identity, next } =
4848
authenticate(credentials::helper::Action::get_for_url(url.clone()))?
49-
.expect("FILL provides an identity or errors");
49+
.ok_or(Error::EmptyCredentials)?;
5050
transport.set_identity(identity)?;
5151
progress.step();
5252
progress.set_name("handshake (authenticated)");

gix-protocol/src/handshake/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ mod error {
6868
pub enum Error {
6969
#[error("Failed to obtain credentials")]
7070
Credentials(#[from] credentials::protocol::Error),
71+
#[error("No credentials were returned at all as if the credential helper isn't functioning unknowingly")]
72+
EmptyCredentials,
7173
#[error("Credentials provided for \"{url}\" were not accepted by the remote")]
7274
InvalidCredentials { url: BString, source: std::io::Error },
7375
#[error(transparent)]

0 commit comments

Comments
 (0)