fix(gitlab): Properly handle auth for Gitlab project avatars (#345)

This commit is contained in:
Gabriel Dugny 2025-06-11 18:33:53 +02:00 committed by GitHub
parent 1ea377e7d6
commit e423b56f42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -121,7 +121,10 @@ export const compileGitlabConfig = async (
const isFork = project.forked_from_project !== undefined;
const repoDisplayName = project.path_with_namespace;
const repoName = path.join(repoNameRoot, repoDisplayName);
// project.avatar_url is not directly accessible with tokens; use the avatar API endpoint if available
const avatarUrl = project.avatar_url
? new URL(`/api/v4/projects/${project.id}/avatar`, hostUrl).toString()
: null;
logger.debug(`Found gitlab repo ${repoDisplayName} with webUrl: ${projectUrl}`);
const record: RepoData = {
@ -132,7 +135,7 @@ export const compileGitlabConfig = async (
webUrl: projectUrl,
name: repoName,
displayName: repoDisplayName,
imageUrl: project.avatar_url,
imageUrl: avatarUrl,
isFork: isFork,
isArchived: !!project.archived,
org: {

View file

@ -419,7 +419,6 @@ export const getRepoImageSrc = (imageUrl: string | undefined, repoId: number, do
// List of known public instances that don't require authentication
const publicHostnames = [
'github.com',
'gitlab.com',
'avatars.githubusercontent.com',
'gitea.com',
'bitbucket.org',