diff --git a/CHANGELOG.md b/CHANGELOG.md index 429b650f3..d96758219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed GitLab connection topic filters (`topics` / `exclude.topics`) being case-sensitive on the project side, so mixed-case GitLab project topics (e.g. `Backend`) now match lowercase config topics. [#1388](https://github.com/sourcebot-dev/sourcebot/issues/1388) + ## [5.1.0] - 2026-07-10 ### Changed diff --git a/packages/backend/src/gitlab.test.ts b/packages/backend/src/gitlab.test.ts index a502488df..956374a87 100644 --- a/packages/backend/src/gitlab.test.ts +++ b/packages/backend/src/gitlab.test.ts @@ -141,16 +141,29 @@ test('shouldExcludeProject returns false when exclude.topics does not match any })).toBe(false); }); -test('shouldExcludeProject include.topics matching is case-sensitive on the project side.', () => { +test('shouldExcludeProject include.topics matching is case-insensitive on the project side.', () => { const project = { path_with_namespace: 'test/project', topics: ['Backend'], } as unknown as ProjectSchema; - // The function lowercases config topics but not project topics, - // so 'Backend' does not match the lowercased pattern 'backend'. + // Both config and project topics are lowercased before matching, + // so the mixed-case project topic 'Backend' matches the pattern 'backend'. expect(shouldExcludeProject({ project, include: { topics: ['backend'] }, + })).toBe(false); +}); + +test('shouldExcludeProject exclude.topics matching is case-insensitive on the project side.', () => { + const project = { + path_with_namespace: 'test/project', + topics: ['Deprecated'], + } as unknown as ProjectSchema; + + // The mixed-case project topic 'Deprecated' matches the exclude pattern 'deprecated'. + expect(shouldExcludeProject({ + project, + exclude: { topics: ['deprecated'] }, })).toBe(true); }); diff --git a/packages/backend/src/gitlab.ts b/packages/backend/src/gitlab.ts index 94a6e0710..6cdadb43a 100644 --- a/packages/backend/src/gitlab.ts +++ b/packages/backend/src/gitlab.ts @@ -249,7 +249,7 @@ export const shouldExcludeProject = ({ if (include?.topics) { const configTopics = include.topics.map(topic => topic.toLowerCase()); - const projectTopics = project.topics ?? []; + const projectTopics = (project.topics ?? []).map(topic => topic.toLowerCase()); const matchingTopics = projectTopics.filter((topic) => micromatch.isMatch(topic, configTopics)); if (matchingTopics.length === 0) { @@ -260,7 +260,7 @@ export const shouldExcludeProject = ({ if (exclude?.topics) { const configTopics = exclude.topics.map(topic => topic.toLowerCase()); - const projectTopics = project.topics ?? []; + const projectTopics = (project.topics ?? []).map(topic => topic.toLowerCase()); const matchingTopics = projectTopics.filter((topic) => micromatch.isMatch(topic, configTopics)); if (matchingTopics.length > 0) {