Skip to content

Conversation

SSUday
Copy link

@SSUday SSUday commented Sep 12, 2025

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

  • Special-case 407 in HttpClientTransport: if status == 407, read content and throw ProxyAuthenticationException with host/URI and details.
  • Parse JSON error if available; otherwise fall back to plain text.

Tests

  • Added ProxyAuthenticationExceptionTests to verify message/cause constructors.
  • (Happy to add/adjust HttpClientTransport tests per reviewer guidance.)

Notes

  • Only improves diagnostics; no success-path behavior changes.

Fixes: #46262

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 12, 2025

String detail = null;
Message json = deserializeMessage(content);
if (json != null && org.springframework.util.StringUtils.hasText(json.getMessage())) {
Copy link
Member

@wilkinsona wilkinsona Sep 18, 2025

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 : "");
Copy link
Member

@wilkinsona wilkinsona Sep 18, 2025

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 {
Copy link
Member

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);
Copy link
Member

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.

@wilkinsona
Copy link
Member

Also, please sign your commits as described in the DCO check failure.

response.close();

if (statusCode == 407) {
response.close();
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants