From 435a5cad5de5c4c2feb232998696ee635f1b4804 Mon Sep 17 00:00:00 2001 From: Claire Peng Date: Thu, 25 Sep 2025 10:46:05 +0100 Subject: [PATCH] update GitlabDiscoverProcessor to call client.hasFile using project.id Signed-off-by: Claire Peng --- .../src/GitLabDiscoveryProcessor.test.ts | 11 ++++++++--- .../src/GitLabDiscoveryProcessor.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts index 774da46553..06ad0b80db 100644 --- a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts +++ b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts @@ -33,6 +33,7 @@ const API_URL = `${SERVER_URL}/api/v4`; const PROJECTS_URL = `${API_URL}/projects`; const GROUP_PROJECTS_URL = `${API_URL}/groups/group%2Fsubgroup/projects`; const EXISTING_PROJECT_PATH = 'exist'; +const EXISTING_PROJECT_ID = 2; const PROJECT_LOCATION: LocationSpec = { type: 'gitlab-discovery', @@ -105,7 +106,7 @@ function setupFakeServer( ); }), rest.head( - `${API_URL}/projects/:project_path/repository/files/:file_path`, + `${API_URL}/projects/:projectIdentifier/repository/files/:file_path`, (req, res, ctx) => { if (req.headers.get('authorization') !== 'Bearer test-token') { return res( @@ -119,7 +120,11 @@ function setupFakeServer( return res(ctx.status(200)); } - if (EXISTING_PROJECT_PATH === req.params.project_path) { + if ( + // Gitlab GET project endpoint can use either numeric project.id or string project.path_with_namespace + EXISTING_PROJECT_ID.toString() === req.params.projectIdentifier || + EXISTING_PROJECT_PATH === req.params.projectIdentifier + ) { return res(ctx.status(200)); } @@ -385,7 +390,7 @@ describe('GitlabDiscoveryProcessor', () => { path_with_namespace: '1', }, { - id: 1, + id: EXISTING_PROJECT_ID, archived: false, default_branch: 'main', last_activity_at: '2021-08-05T11:03:05.774Z', diff --git a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts index 126bb07f03..5ae71dda06 100644 --- a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts +++ b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts @@ -139,7 +139,7 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor { const project_branch = branch === '*' ? project.default_branch : branch; const projectHasFile: boolean = await client.hasFile( - project.path_with_namespace, + project.id, project_branch, catalogPath, );