Skip to content

Commit 0d9c991

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 552d4ce commit 0d9c991

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
@@ -210,6 +210,11 @@ public final class RegistryClient: ContentClient {
210210
throw err
211211
}
212212

213+
continue
214+
} else if _response.status == .badRequest && request.headers.contains(name: "Authorization") {
215+
// Retry without basic auth
216+
request.headers.remove(name: "Authorization")
217+
retryCount += 1
213218
continue
214219
}
215220
guard let retryOptions = self.retryOptions else {

0 commit comments

Comments
 (0)