Skip to content

fix(backend): match GitLab project topics case-insensitively#1443

Open
outrunn wants to merge 1 commit into
sourcebot-dev:mainfrom
outrunn:fix/gitlab-topic-case
Open

fix(backend): match GitLab project topics case-insensitively#1443
outrunn wants to merge 1 commit into
sourcebot-dev:mainfrom
outrunn:fix/gitlab-topic-case

Conversation

@outrunn

@outrunn outrunn commented Jul 14, 2026

Copy link
Copy Markdown

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 configured topics / exclude.topics are lowercased before matching, but the project's own topics (from the GitLab API) are compared in their original case. So a project whose topic is Backend does not match a config topic or glob like backend, 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.topics and exclude.topics branches, so matching is case-insensitive and symmetric between the configured topics and the project topics.

Before / after

Config: include.topics: ["backend"], project topic: ["Backend"]

  • Before: no match -> the repository is excluded from sync.
  • After: case-insensitive match -> the repository is included, as expected.

Testing

  • Updated the existing test that documented the old case-sensitive behavior so it now asserts the mixed-case project topic Backend matches config backend, and added a symmetric exclude.topics test.
  • 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 config topics / exclude.topics are lowercase.

In shouldExcludeProject, project topics are now lowercased before micromatch in both the include.topics and exclude.topics paths, matching the existing lowercasing of config topics so filtering is symmetric and case-insensitive.

Tests were updated to expect inclusion for mixed-case Backend vs backend, plus a new exclude case for Deprecated vs deprecated. 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

    • GitLab topic filters now match project topics without regard to capitalization.
    • Both included and excluded topic rules correctly handle mixed-case topics.
  • Documentation

    • Updated the changelog to document the improved GitLab topic filtering behavior.

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
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

GitLab 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.

Changes

GitLab topic filtering

Layer / File(s) Summary
Normalize project topics for filtering
packages/backend/src/gitlab.ts, packages/backend/src/gitlab.test.ts, CHANGELOG.md
Lowercases GitLab project topics before include and exclude matching, adds mixed-case coverage for both filters, and documents the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: brendan-kellam, msukkari

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: case-insensitive GitLab project topic matching.
Linked Issues check ✅ Passed The code and tests implement case-insensitive topic matching for both include.topics and exclude.topics as requested by #1388.
Out of Scope Changes check ✅ Passed The changes stay focused on the GitLab topic filtering fix, its tests, and the changelog note.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/gitlab-topic-case

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/backend/src/gitlab.ts (1)

251-254: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify case-insensitive matching with micromatch options.

Both include.topics and exclude.topics paths manually create new arrays to map topics to lowercase. micromatch supports 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 both configTopics and projectTopics, and pass { nocase: true } to micromatch.isMatch(topic, include.topics, { nocase: true }).
  • packages/backend/src/gitlab.ts#L262-L265: Remove .map(topic => topic.toLowerCase()) from both configTopics and projectTopics, and pass { nocase: true } to micromatch.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

📥 Commits

Reviewing files that changed from the base of the PR and between a50ca10 and 20a803d.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/backend/src/gitlab.test.ts
  • packages/backend/src/gitlab.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab topic filters are case-sensitive on project topics

1 participant