From 4318c1de50775194990656c05e0bfa7e25584056 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 24 Mar 2026 14:56:30 -0700 Subject: [PATCH 1/2] fix(backend): abort GitLab sync on non-404 API errors to prevent repo deletion Previously, any HTTP error from the GitLab API (including 500s) was converted to a warning and the sync continued with a partial repo list. This caused the database reconciliation to delete repos from the failed group/user/project. Now only 404 errors are treated as warnings (resource not found or no access); all other errors abort the sync so the database is left untouched. Fixes #1029 Co-Authored-By: Claude Sonnet 4.6 --- packages/backend/src/gitlab.ts | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/gitlab.ts b/packages/backend/src/gitlab.ts index 0d74c44a2..94a6e0710 100644 --- a/packages/backend/src/gitlab.ts +++ b/packages/backend/src/gitlab.ts @@ -96,17 +96,15 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = Sentry.captureException(e); logger.error(`Failed to fetch projects for group ${group}.`, e); - const status = e?.cause?.response?.status; - if (status !== undefined) { - const warning = `GitLab API returned ${status}` + if (e?.cause?.response?.status === 404) { + const warning = `Group ${group} not found or no access`; logger.warn(warning); return { type: 'warning' as const, warning - } + }; } - logger.error("No API response status returned"); throw e; } })); @@ -136,17 +134,15 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = Sentry.captureException(e); logger.error(`Failed to fetch projects for user ${user}.`, e); - const status = e?.cause?.response?.status; - if (status !== undefined) { - const warning = `GitLab API returned ${status}` + if (e?.cause?.response?.status === 404) { + const warning = `User ${user} not found or no access`; logger.warn(warning); return { type: 'warning' as const, warning - } + }; } - logger.error("No API response status returned"); throw e; } })); @@ -174,17 +170,15 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = Sentry.captureException(e); logger.error(`Failed to fetch project ${project}.`, e); - const status = e?.cause?.response?.status; - if (status !== undefined) { - const warning = `GitLab API returned ${status}` + if (e?.cause?.response?.status === 404) { + const warning = `Project ${project} not found or no access`; logger.warn(warning); return { type: 'warning' as const, warning - } + }; } - logger.error("No API response status returned"); throw e; } })); From c5c1734be006a759185a2d9b7cfc1eae2c60ca18 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 24 Mar 2026 14:57:05 -0700 Subject: [PATCH 2/2] chore: update CHANGELOG for #1039 Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f4b92ef..74d6e5e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed line numbers being selectable in Safari in the lightweight code highlighter. [#1037](https://github.com/sourcebot-dev/sourcebot/pull/1037) +- Fixed GitLab sync deleting repos when the API returns a non-404 error (e.g. 500) during group/user/project fetch. [#1039](https://github.com/sourcebot-dev/sourcebot/pull/1039) ### Added - Added optional copy button to the lightweight code highlighter (`isCopyButtonVisible` prop), shown on hover. [#1037](https://github.com/sourcebot-dev/sourcebot/pull/1037)