Skip to content

Commit

Permalink
Do not crash on URIs without a host component.
Browse files Browse the repository at this point in the history
URIs such as `unix://...` (Unix domain socket) may legitimately be missing a
host component. We should gracefully handle them when looking for a credential
helper (no such helper can exist for them since the lookup is host-based, but
this could change in the future).

Fixes #16171 which is a regression in 5.3. We had some tests for this in
remote_execution_test.sh, but they were disabled due to flakiness in 8e3c0df.
I've filed #16185 to reenable them.
  • Loading branch information
tjgq committed Aug 29, 2022
1 parent be486b1 commit 85b5e24
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ private CredentialHelperProvider(
public Optional<CredentialHelper> findCredentialHelper(URI uri) {
Preconditions.checkNotNull(uri);

String host = Preconditions.checkNotNull(uri.getHost());
String host = uri.getHost();
if (host == null) {
// Some URIs (e.g. unix://) legitimately have no host component.
return Optional.empty();
}

Optional<Path> credentialHelper =
findHostCredentialHelper(host)
.or(() -> findWildcardCredentialHelper(host))
Expand Down

0 comments on commit 85b5e24

Please sign in to comment.