[GH-ISSUE #2315] [BUG]: GitLab data connector doesn't work for self-hosted instances #1515

Closed
opened 2026-02-22 18:25:13 -05:00 by yindo · 0 comments
Owner

Originally created by @blazeyo on GitHub (Sep 18, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2315

How are you running AnythingLLM?

All versions

What happened?

When adding a GitLab data connector with a self-hosted GitLab instance there's an error

TypeError: branches.map is not a function
    at /home/blazej/llm/tools/anything-llm/collector/utils/extensions/RepoLoader/GitlabRepo/RepoLoader/index.js:183:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async GitLabRepoLoader.getRepoBranches (/home/blazej/llm/tools/anything-llm/collector/utils/extensions/RepoLoader/GitlabRepo/RepoLoader/index.js:171:23)
    at async /home/blazej/llm/tools/anything-llm/collector/extensions/index.js:65:29

The problem is in the UrlPattern matching.

Gitlab.com

The rule works for gitlab.com projects because the domain is explicitly provided

new UrlPattern("https\\://gitlab.com/(:projectId(*))", {
  segmentValueCharset: "a-zA-Z0-9-._~%/+",
}),
GitLabRepoLoader {
  ready: false,
  repo: 'https://gitlab.com/gitlab-com/Product',
  ...
  projectId: 'gitlab-com%2FProduct',
  apiBase: 'https://gitlab.com',
  author: 'gitlab-com',
  project: 'Product',
  branches: []
}

Self-hosted

However, for self-hosted instances the segmentValueCharset is too wide and matches the hostname along with the repository owner

new UrlPattern(
  "(:protocol(http|https))\\://(:hostname*)/(:projectId(*))",
  {
     segmentValueCharset: "a-zA-Z0-9-._~%/+",
  }
),
GitLabRepoLoader {
  ready: false,
  repo: 'https://my.selfhostedinstance.com/me/my-project',
  ...
  projectId: 'my-project',
  apiBase: 'https://my.selfhostedinstance.com',
  author: 'my-project',
  project: undefined,
  branches: []
}

As a result a request is sent to

  • https://my.selfhostedinstance.com/api/v4/projects/my-project/repository/branches instead of
  • https://my.selfhostedinstance.com/api/v4/projects/me%2Fmy-project/repository/branches and returns a 404.

Proposed resolution

  • remove / from segmentValueCharset
  • match the author and project explicitly

Are there known steps to reproduce?

Add any self-hosted GitLab project to the GitLab data connector.

Originally created by @blazeyo on GitHub (Sep 18, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2315 ### How are you running AnythingLLM? All versions ### What happened? When adding a GitLab data connector with a self-hosted GitLab instance there's an error ``` TypeError: branches.map is not a function at /home/blazej/llm/tools/anything-llm/collector/utils/extensions/RepoLoader/GitlabRepo/RepoLoader/index.js:183:27 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async GitLabRepoLoader.getRepoBranches (/home/blazej/llm/tools/anything-llm/collector/utils/extensions/RepoLoader/GitlabRepo/RepoLoader/index.js:171:23) at async /home/blazej/llm/tools/anything-llm/collector/extensions/index.js:65:29 ``` The problem is in the UrlPattern matching. ### Gitlab.com The rule works for gitlab.com projects because the domain is explicitly provided ```js new UrlPattern("https\\://gitlab.com/(:projectId(*))", { segmentValueCharset: "a-zA-Z0-9-._~%/+", }), ``` ```js GitLabRepoLoader { ready: false, repo: 'https://gitlab.com/gitlab-com/Product', ... projectId: 'gitlab-com%2FProduct', apiBase: 'https://gitlab.com', author: 'gitlab-com', project: 'Product', branches: [] } ``` ### Self-hosted However, for self-hosted instances the `segmentValueCharset` is too wide and matches the hostname along with the repository owner ```js new UrlPattern( "(:protocol(http|https))\\://(:hostname*)/(:projectId(*))", { segmentValueCharset: "a-zA-Z0-9-._~%/+", } ), ``` ```js GitLabRepoLoader { ready: false, repo: 'https://my.selfhostedinstance.com/me/my-project', ... projectId: 'my-project', apiBase: 'https://my.selfhostedinstance.com', author: 'my-project', project: undefined, branches: [] } ``` As a result a request is sent to - `https://my.selfhostedinstance.com/api/v4/projects/my-project/repository/branches` instead of - `https://my.selfhostedinstance.com/api/v4/projects/me%2Fmy-project/repository/branches` and returns a 404. ### Proposed resolution - remove `/` from segmentValueCharset - match the author and project explicitly ### Are there known steps to reproduce? Add any self-hosted GitLab project to the GitLab data connector.
yindo added the possible bug label 2026-02-22 18:25:13 -05:00
yindo closed this issue 2026-02-22 18:25:13 -05:00
yindo changed title from [BUG]: GitLab data connector doesn't work for self-hosted instances to [GH-ISSUE #2315] [BUG]: GitLab data connector doesn't work for self-hosted instances 2026-06-05 14:41:09 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#1515