print response body when an http request to ghcr returns unexpected status
This commit is contained in:
@@ -25,6 +25,9 @@ const tarFile: fsHelper.FileMetadata = {
|
||||
const headMockNoExistingBlobs = (): object => {
|
||||
// Simulate none of the blobs existing currently
|
||||
return {
|
||||
text() {
|
||||
return 'Not Found'
|
||||
},
|
||||
status: 404
|
||||
}
|
||||
}
|
||||
@@ -47,6 +50,9 @@ const headMockSomeExistingBlobs = (): object => {
|
||||
} else {
|
||||
// report all others are missing
|
||||
return {
|
||||
text() {
|
||||
return 'Not Found'
|
||||
},
|
||||
status: 404
|
||||
}
|
||||
}
|
||||
@@ -54,6 +60,9 @@ const headMockSomeExistingBlobs = (): object => {
|
||||
|
||||
const headMockFailure = (): object => {
|
||||
return {
|
||||
text() {
|
||||
return 'Failed the head request'
|
||||
},
|
||||
status: 503
|
||||
}
|
||||
}
|
||||
@@ -75,6 +84,9 @@ const postMockSuccessfulIniationForAllBlobs = (): object => {
|
||||
const postMockFailure = (): object => {
|
||||
// Simulate failed initiation of uploads
|
||||
return {
|
||||
text() {
|
||||
return 'Failed the post request'
|
||||
},
|
||||
status: 503
|
||||
}
|
||||
}
|
||||
@@ -110,6 +122,9 @@ const putMockSuccessfulBlobUpload = (url: string): object => {
|
||||
const putMockFailure = (): object => {
|
||||
// Simulate fails upload of all blobs & manifest
|
||||
return {
|
||||
text() {
|
||||
return 'Failed the put request'
|
||||
},
|
||||
status: 500
|
||||
}
|
||||
}
|
||||
@@ -118,6 +133,9 @@ const putMockFailureManifestUpload = (url: string): object => {
|
||||
// Simulate unsuccessful upload of all blobs & then the manifest
|
||||
if (url.includes('manifest')) {
|
||||
return {
|
||||
text() {
|
||||
return 'Failed the put request'
|
||||
},
|
||||
status: 500
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 96.95%"><title>Coverage: 96.95%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#4c1"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">96.95%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">96.95%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 97%"><title>Coverage: 97%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">97%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">97%</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
+9
-5
@@ -104749,7 +104749,8 @@ async function uploadLayer(layer, file, registryURL, checkBlobEndpoint, uploadBl
|
||||
return;
|
||||
}
|
||||
if (checkExistsResponse.status !== 404) {
|
||||
throw new Error(`Unexpected response from blob check for layer ${layer.digest}: ${checkExistsResponse.status} ${checkExistsResponse.statusText}`);
|
||||
const responseBody = await checkExistsResponse.text();
|
||||
throw new Error(`Unexpected response from blob check for layer ${layer.digest}: ${checkExistsResponse.status}. Response Body: ${responseBody}.`);
|
||||
}
|
||||
core.info(`Uploading layer ${layer.digest}.`);
|
||||
const initiateUploadResponse = await fetchWithDebug(uploadBlobEndpoint, {
|
||||
@@ -104760,8 +104761,9 @@ async function uploadLayer(layer, file, registryURL, checkBlobEndpoint, uploadBl
|
||||
body: JSON.stringify(layer)
|
||||
});
|
||||
if (initiateUploadResponse.status !== 202) {
|
||||
core.error(`Unexpected response from upload post ${uploadBlobEndpoint}: ${initiateUploadResponse.status}`);
|
||||
throw new Error(`Unexpected response from POST upload ${initiateUploadResponse.status}`);
|
||||
const responseBody = await initiateUploadResponse.text();
|
||||
core.error(`Unexpected response from upload post ${uploadBlobEndpoint}: ${initiateUploadResponse.status}. Response Body: ${responseBody}.`);
|
||||
throw new Error(`Unexpected response from POST upload ${initiateUploadResponse.status}. Response Body: ${responseBody}.`);
|
||||
}
|
||||
const locationResponseHeader = initiateUploadResponse.headers.get('location');
|
||||
if (locationResponseHeader === undefined) {
|
||||
@@ -104788,7 +104790,8 @@ async function uploadLayer(layer, file, registryURL, checkBlobEndpoint, uploadBl
|
||||
body: data
|
||||
});
|
||||
if (putResponse.status !== 201) {
|
||||
throw new Error(`Unexpected response from PUT upload ${putResponse.status} for layer ${layer.digest}`);
|
||||
const responseBody = await putResponse.text();
|
||||
throw new Error(`Unexpected response from PUT upload ${putResponse.status} for layer ${layer.digest}. Response Body: ${responseBody}.`);
|
||||
}
|
||||
}
|
||||
// Uploads the manifest and returns the digest returned by GHCR
|
||||
@@ -104803,7 +104806,8 @@ async function uploadManifest(manifestJSON, manifestEndpoint, b64Token) {
|
||||
body: manifestJSON
|
||||
});
|
||||
if (putResponse.status !== 201) {
|
||||
throw new Error(`Unexpected response from PUT manifest ${putResponse.status}`);
|
||||
const responseBody = await putResponse.text();
|
||||
throw new Error(`Unexpected response from PUT manifest ${putResponse.status}. Response Body: ${responseBody}.`);
|
||||
}
|
||||
const digestResponseHeader = putResponse.headers.get('docker-content-digest');
|
||||
if (digestResponseHeader === undefined || digestResponseHeader === null) {
|
||||
|
||||
+13
-5
@@ -107,8 +107,10 @@ async function uploadLayer(
|
||||
}
|
||||
|
||||
if (checkExistsResponse.status !== 404) {
|
||||
const responseBody = await checkExistsResponse.text()
|
||||
|
||||
throw new Error(
|
||||
`Unexpected response from blob check for layer ${layer.digest}: ${checkExistsResponse.status} ${checkExistsResponse.statusText}`
|
||||
`Unexpected response from blob check for layer ${layer.digest}: ${checkExistsResponse.status}. Response Body: ${responseBody}.`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -123,11 +125,13 @@ async function uploadLayer(
|
||||
})
|
||||
|
||||
if (initiateUploadResponse.status !== 202) {
|
||||
const responseBody = await initiateUploadResponse.text()
|
||||
|
||||
core.error(
|
||||
`Unexpected response from upload post ${uploadBlobEndpoint}: ${initiateUploadResponse.status}`
|
||||
`Unexpected response from upload post ${uploadBlobEndpoint}: ${initiateUploadResponse.status}. Response Body: ${responseBody}.`
|
||||
)
|
||||
throw new Error(
|
||||
`Unexpected response from POST upload ${initiateUploadResponse.status}`
|
||||
`Unexpected response from POST upload ${initiateUploadResponse.status}. Response Body: ${responseBody}.`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -161,8 +165,10 @@ async function uploadLayer(
|
||||
})
|
||||
|
||||
if (putResponse.status !== 201) {
|
||||
const responseBody = await putResponse.text()
|
||||
|
||||
throw new Error(
|
||||
`Unexpected response from PUT upload ${putResponse.status} for layer ${layer.digest}`
|
||||
`Unexpected response from PUT upload ${putResponse.status} for layer ${layer.digest}. Response Body: ${responseBody}.`
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -185,8 +191,10 @@ async function uploadManifest(
|
||||
})
|
||||
|
||||
if (putResponse.status !== 201) {
|
||||
const responseBody = await putResponse.text()
|
||||
|
||||
throw new Error(
|
||||
`Unexpected response from PUT manifest ${putResponse.status}`
|
||||
`Unexpected response from PUT manifest ${putResponse.status}. Response Body: ${responseBody}.`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user