diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ba076ab..4f196596 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed issue with filtering on generic git repo indexed from http/https [#742](https://github.com/sourcebot-dev/sourcebot/pull/742) +- Fixed auth error when trying to sync public gitlab.com project with no token [#748](https://github.com/sourcebot-dev/sourcebot/pull/748) - Fixed "Ranges must be added sorted by `from` position and `startSide`" error when browsing certain files. [#743](https://github.com/sourcebot-dev/sourcebot/pull/743) ## [4.10.10] - 2026-01-16 diff --git a/packages/backend/src/ee/repoPermissionSyncer.ts b/packages/backend/src/ee/repoPermissionSyncer.ts index 802da032..eb9edc67 100644 --- a/packages/backend/src/ee/repoPermissionSyncer.ts +++ b/packages/backend/src/ee/repoPermissionSyncer.ts @@ -177,7 +177,7 @@ export class RepoPermissionSyncer { const accountIds = await (async () => { if (repo.external_codeHostType === 'github') { - const isGitHubCloud = credentials.hostUrl ? new URL(credentials.hostUrl).hostname === GITHUB_CLOUD_HOSTNAME : false; + const isGitHubCloud = credentials.hostUrl ? new URL(credentials.hostUrl).hostname === GITHUB_CLOUD_HOSTNAME : true; const { octokit } = await createOctokitFromToken({ token: credentials.token, url: isGitHubCloud ? undefined : credentials.hostUrl, diff --git a/packages/backend/src/github.ts b/packages/backend/src/github.ts index 85169058..a43d81f0 100644 --- a/packages/backend/src/github.ts +++ b/packages/backend/src/github.ts @@ -47,7 +47,7 @@ const isHttpError = (error: unknown, status: number): boolean => { } export const createOctokitFromToken = async ({ token, url }: { token?: string, url?: string }): Promise<{ octokit: Octokit, isAuthenticated: boolean }> => { - const isGitHubCloud = url ? new URL(url).hostname === GITHUB_CLOUD_HOSTNAME : false; + const isGitHubCloud = url ? new URL(url).hostname === GITHUB_CLOUD_HOSTNAME : true; const octokit = new Octokit({ auth: token, ...(url && !isGitHubCloud ? { diff --git a/packages/backend/src/gitlab.ts b/packages/backend/src/gitlab.ts index 5d07985e..14b8702f 100644 --- a/packages/backend/src/gitlab.ts +++ b/packages/backend/src/gitlab.ts @@ -12,9 +12,9 @@ const logger = createLogger('gitlab'); export const GITLAB_CLOUD_HOSTNAME = "gitlab.com"; export const createGitLabFromPersonalAccessToken = async ({ token, url }: { token?: string, url?: string }) => { - const isGitLabCloud = url ? new URL(url).hostname === GITLAB_CLOUD_HOSTNAME : false; + const isGitLabCloud = url ? new URL(url).hostname === GITLAB_CLOUD_HOSTNAME : true; return new Gitlab({ - token, + ...(token ? { token } : {}), ...(isGitLabCloud ? {} : { host: url, }), @@ -23,9 +23,9 @@ export const createGitLabFromPersonalAccessToken = async ({ token, url }: { toke } export const createGitLabFromOAuthToken = async ({ oauthToken, url }: { oauthToken?: string, url?: string }) => { - const isGitLabCloud = url ? new URL(url).hostname === GITLAB_CLOUD_HOSTNAME : false; + const isGitLabCloud = url ? new URL(url).hostname === GITLAB_CLOUD_HOSTNAME : true; return new Gitlab({ - oauthToken, + ...(oauthToken ? { oauthToken } : {}), ...(isGitLabCloud ? {} : { host: url, }), @@ -99,7 +99,7 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = const status = e?.cause?.response?.status; if (status !== undefined) { const warning = `GitLab API returned ${status}` - logger.warning(warning); + logger.warn(warning); return { type: 'warning' as const, warning @@ -139,7 +139,7 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = const status = e?.cause?.response?.status; if (status !== undefined) { const warning = `GitLab API returned ${status}` - logger.warning(warning); + logger.warn(warning); return { type: 'warning' as const, warning @@ -177,7 +177,7 @@ export const getGitLabReposFromConfig = async (config: GitlabConnectionConfig) = const status = e?.cause?.response?.status; if (status !== undefined) { const warning = `GitLab API returned ${status}` - logger.warning(warning); + logger.warn(warning); return { type: 'warning' as const, warning