Fix: bad request will remove header and retry login (#711)

If you're requesting on `/v2/` with basic auth, AWS ECR will return 400
Bad Request and won't provide `www-authenticate` information.

Retry the request after removing the Authorization header.

Continue PR #429

Fixed apple/container#847

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
This commit is contained in:
ChengHao Yang authored and GitHub committed 2026-04-29 15:29:54 -04:00
1 parent b62edd2e2d
commit de075fff8a
1 file changed
+5
@@ -210,6 +210,11 @@ public final class RegistryClient: ContentClient {
throw err
}
continue
} else if _response.status == .badRequest && request.headers.contains(name: "Authorization") {
// Retry without basic auth
request.headers.remove(name: "Authorization")
retryCount += 1
continue
}
guard let retryOptions = self.retryOptions else {