Skip to content

Commit 51ebf50

Browse files
committed
Fix: bad request will remove header and retry login
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. Signed-off-by: ChengHao Yang <[email protected]>
1 parent 4a8f945 commit 51ebf50

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/ContainerizationOCI/Client/RegistryClient.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ public final class RegistryClient: ContentClient {
203203
throw err
204204
}
205205

206+
continue
207+
} else if _response.status == .badRequest && request.headers.contains(name: "Authorization") {
208+
// Retry without basic auth
209+
request.headers.remove(name: "Authorization")
210+
retryCount += 1
206211
continue
207212
}
208213
guard let retryOptions = self.retryOptions else {

0 commit comments

Comments
 (0)