From 3616c8d5e68f0615bad009b735b47f7e5aac4ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Nagygy=C3=B6rgy?= Date: Mon, 16 Dec 2024 10:20:14 +0100 Subject: [PATCH] fix: handle v2 http api exceptions --- .../registry-clients/v2-http-api-client.ts | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/web/crux/src/app/registry/registry-clients/v2-http-api-client.ts b/web/crux/src/app/registry/registry-clients/v2-http-api-client.ts index 3d8fc4003..5bf7744b3 100644 --- a/web/crux/src/app/registry/registry-clients/v2-http-api-client.ts +++ b/web/crux/src/app/registry/registry-clients/v2-http-api-client.ts @@ -414,24 +414,36 @@ export default class V2HttpApiClient { } async fetchLabels(image: string, tag: string): Promise> { - const tagManifest = await this.fetchTagManifest(image, tag) - if (!tagManifest) { + try { + const tagManifest = await this.fetchTagManifest(image, tag) + if (!tagManifest) { + return {} + } + + return this.fetchLabelsByManifest(image, tagManifest, 0) + } catch (err: any) { + this.logger.error(`Failed to fetch labels '${image}:${tag}'`) + this.logger.error(`${err.name} ${err.message}`, err.stack) return {} } - - return this.fetchLabelsByManifest(image, tagManifest, 0) } async fetchTagInfo(image: string, tag: string): Promise { - const tagManifest = await this.fetchTagManifest(image, tag) - if (!tagManifest) { - return null - } + try { + const tagManifest = await this.fetchTagManifest(image, tag) + if (!tagManifest) { + return null + } - const configBlob = await this.fetchConfigBlobByManifest(image, tagManifest, 0) + const configBlob = await this.fetchConfigBlobByManifest(image, tagManifest, 0) - return { - created: configBlob.created, + return { + created: configBlob.created, + } + } catch (err: any) { + this.logger.error(`Failed to fetch tag info '${image}:${tag}'`) + this.logger.error(`${err.name} ${err.message}`, err.stack) + return null } } }