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) 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; } }));