Skip to content

Fix GitLab repo-fetch parent derivation and its test mock - #703

Open
blockgroot wants to merge 1 commit into
middlewarehq:mainfrom
blockgroot:fix/702-gitlab-repo-fetch-test-mock
Open

Fix GitLab repo-fetch parent derivation and its test mock#703
blockgroot wants to merge 1 commit into
middlewarehq:mainfrom
blockgroot:fix/702-gitlab-repo-fetch-test-mock

Conversation

@blockgroot

@blockgroot blockgroot commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Fixes #702.

fetchRepos's GitLab branch (web-server/pages/api/internal/[org_id]/git_org_repos.ts)
re-derived parent from repo.fullPath via string splitting, even though the GraphQL
query already fetches namespace.fullPath — the field that directly represents it. The
derivation is mathematically equivalent for well-formed data, so it wasn't a production
bug, but it was redundant, and it was the root cause of a stale test fixture: the mock's
fullPath and namespace.fullPath were mutually inconsistent with each other, and its
id wasn't shaped like a real GitLab GID (gid://gitlab/Project/...). Both caused the
GitLab case of fetchRepos's test to fail ever since it was introduced in #672.

Changes

  • git_org_repos.ts: read parent from repo.namespace.fullPath directly instead of
    re-deriving it from repo.fullPath.
  • git_org_repos.test.ts: use a realistic, internally-consistent GitLab GraphQL mock
    (GID-shaped id, fullPath/namespace.fullPath that agree with each other), and
    correct the assertion's expected id to a number, matching what the implementation
    actually returns.

Test plan

  • cd web-server && npx jest --watchAll=false --passWithNoTests -t "fetchRepos" — both
    GitHub and GitLab cases now pass (previously the GitLab case failed).
  • npx tsc --noEmit — clean.
  • npx eslint "pages/api/internal/[org_id]/git_org_repos.ts" — no new findings (verified
    identical pre-existing warning/error count on main before this change; this file has
    pre-existing lint debt unrelated to this fix, left untouched per scope).

Summary by CodeRabbit

  • Bug Fixes
    • Improved GitLab repository organization mapping for more accurate parent relationships.
    • Updated repository identification to use numeric project IDs consistently.

parent was re-derived from repo.fullPath via string splitting, even
though the GraphQL query already fetches namespace.fullPath, the
field that actually represents it. The derivation happens to be
equivalent for well-formed data, but is redundant and was the source
of a stale test fixture whose fullPath and namespace.fullPath were
mutually inconsistent (and whose id wasn't shaped like a real GitLab
GID), causing the GitLab case of the fetchRepos test to fail since
it was introduced in middlewarehq#672.

Use namespace.fullPath directly and fix the mock to match a real
GitLab GraphQL response shape.

Fixes middlewarehq#702
@CLAassistant

CLAassistant commented Aug 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7dbe9bab-9859-4817-92bc-7867aa7754a9

📥 Commits

Reviewing files that changed from the base of the PR and between 844eb42 and ca78904.

📒 Files selected for processing (2)
  • web-server/pages/api/internal/[org_id]/__tests__/git_org_repos.test.ts
  • web-server/pages/api/internal/[org_id]/git_org_repos.ts

Walkthrough

The GitLab repository fixture now uses a global project ID and a consistent full path. Repository mapping now reads the parent from namespace.fullPath.

Changes

GitLab repository mapping

Layer / File(s) Summary
GitLab mapping and test validation
web-server/pages/api/internal/[org_id]/git_org_repos.ts, web-server/pages/api/internal/[org_id]/__tests__/git_org_repos.test.ts
The mapper uses repo.namespace.fullPath for parent. The test fixture uses a GitLab global project ID and expects numeric ID 101.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to ca789

The PR makes a localized GitLab parent-path correction and aligns its test mock with the implementation; no actionable merge-blocking risk remains after normal checks and review.

Poem

I’m a rabbit with a repo to tend,
A namespace path now marks the bend.
Global IDs hop into place,
Tests find their proper trace.
GitLab mapping reaches the end!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the GitLab parent derivation fix and the related test mock update.
Description check ✅ Passed The description identifies issue #702, explains the cause, lists the changes, and documents the test plan.
Linked Issues check ✅ Passed The changes satisfy issue #702 by correcting the GitLab GID mock, aligning paths, fixing the ID expectation, and using namespace.fullPath.
Out of Scope Changes check ✅ Passed All changes remain within the linked issue scope and address GitLab repository mapping and its test fixture.
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

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.

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.

git_org_repos.test.ts GitLab test fails due to unrealistic mock data, not a code bug

2 participants