From 1e5cf7c8bf07693fbf43ad33b29762e6573f1717 Mon Sep 17 00:00:00 2001 From: Michael Sukkarieh Date: Tue, 23 Dec 2025 11:25:06 -0500 Subject: [PATCH] fix(gitlab): Better error logs for gitlab config sync (#692) --- CHANGELOG.md | 1 + packages/backend/src/gitlab.ts | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0897c85a..c9146227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bake Sourcebot version into code rather than relying on build arg. [#680](https://github.com/sourcebot-dev/sourcebot/pull/680) - Fix issue with `/repos` page pagination. [#689](https://github.com/sourcebot-dev/sourcebot/pull/689) +- Add better logs for gitlab config sync fails. [#692](https://github.com/sourcebot-dev/sourcebot/pull/692) ## [4.10.4] - 2025-12-18 diff --git a/packages/backend/src/gitlab.ts b/packages/backend/src/gitlab.ts index b461d59b..44685424 100644 --- a/packages/backend/src/gitlab.ts +++ b/packages/backend/src/gitlab.ts @@ -97,14 +97,16 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = logger.error(`Failed to fetch projects for group ${group}.`, e); const status = e?.cause?.response?.status; - if (status === 404) { - const warning = `Group ${group} not found or no access`; - logger.warn(warning); + if (status !== undefined) { + const warning = `GitLab API returned ${status}` + logger.warning(warning); return { type: 'warning' as const, warning - }; + } } + + logger.error("No API response status returned"); throw e; } })); @@ -135,14 +137,16 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = logger.error(`Failed to fetch projects for user ${user}.`, e); const status = e?.cause?.response?.status; - if (status === 404) { - const warning = `User ${user} not found or no access`; - logger.warn(warning); + if (status !== undefined) { + const warning = `GitLab API returned ${status}` + logger.warning(warning); return { type: 'warning' as const, warning - }; + } } + + logger.error("No API response status returned"); throw e; } })); @@ -171,15 +175,16 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = logger.error(`Failed to fetch project ${project}.`, e); const status = e?.cause?.response?.status; - - if (status === 404) { - const warning = `Project ${project} not found or no access`; - logger.warn(warning); + if (status !== undefined) { + const warning = `GitLab API returned ${status}` + logger.warning(warning); return { type: 'warning' as const, warning - }; + } } + + logger.error("No API response status returned"); throw e; } }));