fix(backend): match GitLab topics case-insensitively - #1393
Conversation
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
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
ChangesGitLab topic case-insensitive filtering
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
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
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
packages/backend/src/gitlab.test.tspackages/backend/src/gitlab.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
…ic-case # Conflicts: # CHANGELOG.md
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
shouldExcludeProjectnormalized 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.tsnode .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/backend buildRisk
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
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.
shouldExcludeProjectalready 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.topicsandexclude.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.