fix(backend): match GitLab project topics case-insensitively#1443
fix(backend): match GitLab project topics case-insensitively#1443outrunn wants to merge 1 commit into
Conversation
GitLab connection topic filters lowercased the configured topics but compared them against project topics in their original case, so a project topic like 'Backend' would not match a config topic such as 'backend'. Lowercase the project topics as well so include/exclude topic matching is case-insensitive and symmetric. Fixes sourcebot-dev#1388
WalkthroughGitLab project topics are lowercased before matching against configured include and exclude topic filters. Tests cover mixed-case project topics for both paths, and the changelog documents the case-insensitive behavior. ChangesGitLab topic filtering
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/backend/src/gitlab.ts (1)
251-254: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify case-insensitive matching with
micromatchoptions.Both
include.topicsandexclude.topicspaths manually create new arrays to map topics to lowercase.micromatchsupports case-insensitive matching natively via the{ nocase: true }option, which would allow you to skip creating intermediate lowercased arrays.Consider refactoring both sections to use the native option:
packages/backend/src/gitlab.ts#L251-L254: Remove.map(topic => topic.toLowerCase())from bothconfigTopicsandprojectTopics, and pass{ nocase: true }tomicromatch.isMatch(topic, include.topics, { nocase: true }).packages/backend/src/gitlab.ts#L262-L265: Remove.map(topic => topic.toLowerCase())from bothconfigTopicsandprojectTopics, and pass{ nocase: true }tomicromatch.isMatch(topic, exclude.topics, { nocase: true }).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/backend/src/gitlab.ts` around lines 251 - 254, The topic matching logic in both include and exclude paths unnecessarily lowercases intermediate arrays. In packages/backend/src/gitlab.ts lines 251-254, remove the lowercase mappings and use the original topic arrays with micromatch.isMatch configured with nocase: true; apply the same change to lines 262-265 for exclude.topics, preserving the existing matching behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/backend/src/gitlab.ts`:
- Around line 251-254: The topic matching logic in both include and exclude
paths unnecessarily lowercases intermediate arrays. In
packages/backend/src/gitlab.ts lines 251-254, remove the lowercase mappings and
use the original topic arrays with micromatch.isMatch configured with nocase:
true; apply the same change to lines 262-265 for exclude.topics, preserving the
existing matching behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a9067891-a1c0-498d-9d1f-315d76e39e56
📒 Files selected for processing (3)
CHANGELOG.mdpackages/backend/src/gitlab.test.tspackages/backend/src/gitlab.ts
Fixes #1388
Problem
GitLab connection topic filters are case-insensitive on the config side but case-sensitive on the project side. In
shouldExcludeProject(packages/backend/src/gitlab.ts), the configuredtopics/exclude.topicsare lowercased before matching, but the project's own topics (from the GitLab API) are compared in their original case. So a project whose topic isBackenddoes not match a config topic or glob likebackend, and repositories get unexpectedly included or excluded whenever a GitLab project uses mixed-case topics.Fix
Lowercase the project topics as well, in both the
include.topicsandexclude.topicsbranches, so matching is case-insensitive and symmetric between the configured topics and the project topics.Before / after
Config:
include.topics: ["backend"], project topic:["Backend"]Testing
Backendmatches configbackend, and added a symmetricexclude.topicstest.yarn workspace @sourcebot/backend test --run src/gitlab.test.ts-> 13/13 passing.yarn workspace @sourcebot/backend exec tsc --noEmit-> clean.Changelog
Added an entry under
## [Unreleased]->### Fixed.Note on #1393
I saw #1393 takes the same approach but has unresolved conflicts and looks stale. Opening this as a clean, rebased alternative with tests in case it helps land the fix faster. Happy to close this one if the original author picks theirs back up.
Note
Low Risk
Narrow change to GitLab topic filter matching during connection sync; may include or exclude repos that were wrong before, with no auth or data-model impact.
Overview
Fixes GitLab connection sync wrongly including or excluding repos when GitLab project topics use mixed case (e.g.
Backend) while configtopics/exclude.topicsare lowercase.In
shouldExcludeProject, project topics are now lowercased beforemicromatchin both theinclude.topicsandexclude.topicspaths, matching the existing lowercasing of config topics so filtering is symmetric and case-insensitive.Tests were updated to expect inclusion for mixed-case
Backendvsbackend, plus a new exclude case forDeprecatedvsdeprecated. An Unreleased changelog entry documents the fix (#1388).Reviewed by Cursor Bugbot for commit 20a803d. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Documentation