Skip to content

Commit 56712fe

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 <17496418+tico88612@users.noreply.github.com>
1 parent 9ba8267 commit 56712fe

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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)