@@ -94,7 +94,9 @@ async def _basic_auth_registry_request(
9494 raise ServiceNotAvailableError (service_name = path )
9595
9696 elif response .status_code >= status .HTTP_400_BAD_REQUEST :
97- raise RegistryConnectionError (msg = str (response ))
97+ raise RegistryConnectionError (
98+ msg = f"{ response } : { response .text } for { request_url } "
99+ )
98100
99101 else :
100102 # registry that does not need an auth
@@ -165,7 +167,9 @@ async def _auth_registry_request( # noqa: C901
165167 if resp_wbasic .status_code == status .HTTP_404_NOT_FOUND :
166168 raise ServiceNotAvailableError (service_name = f"{ url } " )
167169 if resp_wbasic .status_code >= status .HTTP_400_BAD_REQUEST :
168- raise RegistryConnectionError (msg = f"{ resp_wbasic } " )
170+ raise RegistryConnectionError (
171+ msg = f"{ resp_wbasic } : { resp_wbasic .text } for { url } "
172+ )
169173 resp_data = await resp_wbasic .json (content_type = None )
170174 resp_headers = resp_wbasic .headers
171175 return (resp_data , resp_headers )
@@ -199,7 +203,22 @@ async def registry_request(
199203 if use_cache and (cached_response := await cache .get (cache_key )):
200204 assert isinstance (cached_response , tuple ) # nosec
201205 return cast (tuple [dict , Mapping ], cached_response )
202-
206+ # Add proper Accept headers for manifest requests for accepting both v1 and v2
207+ if "manifests/" in path and method .upper () == "GET" :
208+ headers = session_kwargs .get ("headers" , {})
209+ headers .update (
210+ {
211+ "Accept" : ", " .join (
212+ [
213+ "application/vnd.docker.distribution.manifest.v2+json" ,
214+ "application/vnd.docker.distribution.manifest.list.v2+json" ,
215+ "application/vnd.docker.distribution.manifest.v1+prettyjws" ,
216+ "application/json" ,
217+ ]
218+ )
219+ }
220+ )
221+ session_kwargs ["headers" ] = headers
203222 app_settings = get_application_settings (app )
204223 try :
205224 response , response_headers = await _retried_request (
0 commit comments