Skip to content

Commit 942c601

Browse files
fix: return error
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
1 parent 12168e9 commit 942c601

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

util/git/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ func buildSSHAuth(repoURL string, creds *SSHCreds) (transport.AuthMethod, error)
398398

399399
cb, algos, err := resolveSSHHostKeyConfig(repoURL)
400400
if err != nil {
401-
log.Errorf("Could not set-up SSH known hosts callback for %s: %v", repoURL, err)
401+
// Returning the error rather than continuing with a nil callback
402+
// avoids handing back an AuthMethod with no host-key verification.
403+
// For the no-credentials path, newAuth catches this and lets go-git
404+
// fall back to its DefaultAuthBuilder.
405+
return nil, fmt.Errorf("could not set up SSH known hosts callback for %s: %w", repoURL, err)
402406
}
403407

404408
if creds == nil {

0 commit comments

Comments
 (0)