Skip to content

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

Merged
brendan-kellam merged 7 commits into
sourcebot-dev:mainfrom
DivyamTalwar:divyam/fix-gitlab-topic-case
Aug 4, 2026
Merged

fix(backend): match GitLab topics case-insensitively#1393
brendan-kellam merged 7 commits into
sourcebot-dev:mainfrom
DivyamTalwar:divyam/fix-gitlab-topic-case

Conversation

@DivyamTalwar

@DivyamTalwar DivyamTalwar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1388

Problem

GitLab topic filters lowercased configured topics but compared them against project topics without normalizing the project side, so mixed-case GitLab topics could miss matching include/exclude filters.

Root cause

shouldExcludeProject normalized config topics only.

Solution

Normalize project topics before both include and exclude matching, keeping the comparison symmetric and case-insensitive.

Tests

  • node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend test src/gitlab.test.ts
  • node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend build

Risk

Low to moderate. This intentionally changes mixed-case GitLab topic filtering so matching is case-insensitive for both include and exclude rules.

Summary by CodeRabbit

  • Bug Fixes
    • GitLab topic include/exclude filters now match project topics case-insensitively.
    • Projects with mixed-case topics are evaluated consistently against configured topic rules.

Note

Low Risk
Behavior change is limited to GitLab project filtering during connection sync; mixed-case topic rules may now include or exclude projects that previously slipped through, which is the intended fix rather than a security regression.

Overview
GitLab connection sync now treats include/exclude topic filters as case-insensitive on both sides. shouldExcludeProject already lowercased configured topics but left project topics as returned by GitLab, so mixed-case topics (e.g. Backend, Core-API) could be wrongly excluded or not excluded.

Project topics are lowercased before micromatch runs for both include.topics and exclude.topics, matching the config side and aligning with the intended behavior documented in the changelog.

Tests were updated to expect case-insensitive matches (including globs) instead of asserting case-sensitive failure on the project side.

Reviewed by Cursor Bugbot for commit 5a9cac2. Bugbot is set up for automated code reviews on this repo. Configure here.

Normalize GitLab project topics before include/exclude matching so mixed-case GitLab topics obey the lowercased filter patterns.\n\nConstraint: GitLab connection configs already normalize configured topic filters to lowercase.\nRejected: Preserve project-side case sensitivity | it makes mixed-case GitLab topics fail otherwise matching filters.\nConfidence: high\nScope-risk: narrow\nDirective: Keep GitLab topic include and exclude matching symmetric.\nTested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend test src/gitlab.test.ts; node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend build\nNot-tested: Live GitLab API sync against mixed-case project topics
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

shouldExcludeProject now lowercases GitLab project topics before matching include and exclude topic filters. Tests and the changelog document case-insensitive matching.

Changes

GitLab topic case-insensitive filtering

Layer / File(s) Summary
shouldExcludeProject topic normalization
packages/backend/src/gitlab.ts
project.topics values are lowercased before micromatch evaluates include.topics and exclude.topics.
Case-insensitive behavior tests and changelog
packages/backend/src/gitlab.test.ts, CHANGELOG.md
Tests cover mixed-case include and exclude topics. The changelog records the fix.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #1388 by normalizing project topics for case-insensitive include and exclude matching, including glob patterns.
Out of Scope Changes check ✅ Passed All changes support the linked issue through implementation, tests, and changelog documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 matching for GitLab topics.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Document the GitLab topic case-insensitive matching fix in the Unreleased changelog after the PR number was assigned.\n\nConstraint: Sourcebot requires every PR to include a changelog entry with the PR link.\nConfidence: high\nScope-risk: narrow\nDirective: Keep changelog entries as follow-up commits once PR numbers exist.\nTested: not run; changelog-only change\nNot-tested: Runtime behavior

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

Actionable comments posted: 1

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

Inline comments:
In `@packages/backend/src/gitlab.test.ts`:
- Around line 144-166: The existing `shouldExcludeProject` tests cover
case-insensitive exact topic matches, but they do not verify glob patterns; add
a regression test alongside the current `shouldExcludeProject` cases that uses a
mixed-case topic and a lowercase glob in `include.topics` (for example, a
project topic like `Core-API` matched by `core-*`) and assert the project is not
excluded. Keep the new test in the same `gitlab.test.ts` suite so the
case-insensitive glob behavior of `shouldExcludeProject` is explicitly covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e824e3e-b757-445a-b7df-d5c8117613e0

📥 Commits

Reviewing files that changed from the base of the PR and between 82b5c1f and 583d8df.

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

Comment thread packages/backend/src/gitlab.test.ts
Add a regression for mixed-case GitLab project topics matching lowercase include-topic glob filters.\n\nConstraint: CodeRabbit requested explicit glob coverage for the new case-insensitive topic matching behavior.\nConfidence: high\nScope-risk: narrow\nDirective: Keep topic filter behavior covered for exact and glob patterns.\nTested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend test src/gitlab.test.ts; node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend build\nNot-tested: Live GitLab API sync against mixed-case project topics
@brendan-kellam
brendan-kellam enabled auto-merge (squash) August 4, 2026 18:01
@brendan-kellam
brendan-kellam disabled auto-merge August 4, 2026 20:28
@brendan-kellam
brendan-kellam merged commit 5824c1b into sourcebot-dev:main Aug 4, 2026
7 checks passed
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

2 participants