-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Handle Docker 407 (Proxy Authentication Required) with clear error message #47180
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
base: 3.3.x
Are you sure you want to change the base?
Conversation
|
||
String detail = null; | ||
Message json = deserializeMessage(content); | ||
if (json != null && org.springframework.util.StringUtils.hasText(json.getMessage())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringUtils
is already imported so there's no need to fully-qualify the type.
|
||
String msg = "Proxy authentication required for host: " + this.host.toHostString() + ", uri: " | ||
+ request.getUri() | ||
+ (org.springframework.util.StringUtils.hasText(detail) ? " - " + detail : ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringUtils
is already imported so there's no need to fully-qualify the type.
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ProxyAuthenticationExceptionTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need tests for ProxyAuthenticationException
. Please remove this class.
detail = json.getMessage(); | ||
} | ||
else { | ||
detail = new String(content, java.nio.charset.StandardCharsets.UTF_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StandardCharsets
should be imported rather than using the fully-qualified type here.
Also, please sign your commits as described in the DCO check failure. |
response.close(); | ||
|
||
if (statusCode == 407) { | ||
response.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong to me as the response will now only be closed when the status code is 407.
Problem
When Docker returns 407 (Proxy Authentication Required), the response is often plain text, so the current code fails to surface a helpful error.
Solution
Tests
Notes
Fixes: #46262