Merge pull request #2403 from balena-os/dont-revert-to-regular-pull-if-401

Don't revert to regular pull if delta server 401
This commit is contained in:
flowzone-app[bot] 2025-03-03 13:41:29 +00:00 committed by GitHub
commit 91335051ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -219,9 +219,17 @@ export async function fetchDeltaWithProgress(
}
break;
case 3:
// If 400s status code, throw a more specific error & revert immediately to a regular pull
// If 400s status code, throw a more specific error & revert immediately to a regular pull,
// unless the code is 401 Unauthorized, in which case we should surface the error by retrying
// the delta server request, instead of falling back to a regular pull immediately.
if (res.statusCode >= 400 && res.statusCode < 500) {
throw new DeltaServerError(res.statusCode, res.statusMessage);
if (res.statusCode === 401) {
throw new Error(
`Got ${res.statusCode} when requesting an image from delta server: ${res.statusMessage}`,
);
} else {
throw new DeltaServerError(res.statusCode, res.statusMessage);
}
}
if (res.statusCode !== 200) {
throw new Error(