Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): GitLab merge requests can expand unchanged lines #17528

MergedScottN-PV(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/17528/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Problem

Clicking an "N unmodified lines" divider in a GitLab merge request's Code tab does nothing. The server refuses with "This host cannot expand unchanged pull request lines." because the GitLab provider never exposes getDiffFileContents, and the web client only logs the error to the console.

Change

The GitLab provider now wires getDiffFileContents to the existing GitLabPullRequestCli.getMergeRequestDiffFileContents (added in #5546), the way the GitHub provider wires its CLI read.

Scope and approval

Refs #17156. The triage comment locates the missing wiring and proposes this change. Its second problem, the web client swallowing expansion failures, needs a UX decision and is left out, so this does not close the issue. Bitbucket, which the triage says may have the same gap, is also left out.

Verification

Ubuntu 24.04 dev server:

  • Provider tests with a mocked GitLab CLI: a read for the whole merge request and for one commit reaches the CLI with the same input, and a binary file comes back as a failed getDiffFileContents read. Both fail without the fix ("expected undefined to not equal undefined"). In apps/server, vp test run src/pullRequest/GitLabPullRequestProvider.test.ts src/pullRequest/GitLabPullRequestCli.test.ts src/pullRequest/PullRequestService.test.ts: 261 passed. Server typecheck, vp lint, and vp fmt --check on the changed files: clean.
  • After rebasing onto #17594, which moved the provider to packages/source-control-gitlab: vp test run there passes 135 tests in 5 files, and both new tests still fail without the fix. Package typecheck, vp lint, and vp fmt --check on the two changed files pass.
  • Real run with glab signed in to gitlab.com (read-only token) against gitlab-org/cli!4040 (a fork merge request, head d8209e45af), web client driven by headless Chromium at 1280×800. Before the fix, clicking "20 unmodified lines" in create.go leaves the divider in place and the console logs the error above. After the fix, the same click replaces the divider with the hidden lines from 507 and logs nothing.

Before:

Before: the divider stays after the click

https://github.com/user-attachments/assets/adc9c95a-eb3e-4168-a26b-204af2dad8df

After:

After: the hidden lines replace the divider

https://github.com/user-attachments/assets/3a426c19-255c-4ddc-9e8a-5634a66fd9b9

Not checked: self-managed GitLab and the desktop app.

Model: Claude Opus 5.5, Claude Fable 5.1 (review), GPT-6-Astra (review). Harness: Claude Code, Codex.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 2d8e16d

      Macroscope's review found this PR approvable — This narrowly wires GitLab’s existing file-content reader into the provider so users can expand unchanged diff lines, with focused coverage for normal and failed reads. Existing behavior remains unchanged outside that explicit expansion action.

      No code changes detected at 31df44f. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 710ede5f-37e9-404d-883f-5610472a1fcf


      📥 Commits

      Reviewing files that changed from the base of the PR and between 2d8e16d9b68cff18c22414d6f2bb9d409757bec7 and 31df44f949eb213409a6925f75841645c9bd0b13.



      📒 Files selected for processing (2)
      • packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
      • packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts


      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.




      📝 Walkthrough
      📝 Walkthrough

      Walkthrough

      The GitLab pull request provider now delegates diff-file content requests to the GitLab CLI and maps CLI failures to provider errors. Tests cover returned file contents, request forwarding, and binary-file errors.

      Changes

      GitLab diff file reads

      Layer / File(s)Summary
      Read diff file contents
      packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts, packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
      The provider forwards diff-file content requests to the CLI and maps CLI errors to provider errors. Tests cover merge-request and commit-specific requests, returned file contents, and binary-file error details.

      Priority: ➖ Normal

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

      Change: Bug fix

      Suggested reviewers: juliusmarminge




      Merge Risk: ⚪ Minimal · up to 31df4

      GitLab diff expansion is ready to merge after normal checks; no actionable risk is identified in this change.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to 31df4

      This enables authenticated reads of complete GitLab files. Existing access controls remain, and no bypass was identified. Access is broader than the displayed merge-request changes and can extend to repositories available to the server's GitLab account.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The effective read scope can include complete text files in caller-selected repositories on a configured GitLab host, subject to the server's GitLab permissions. It is not limited to the selected project's repository, changed paths, or commits belonging to the named merge request: hosted routing allows repository substitution, paths are caller-selected, and commit-specific reads use the repository commit endpoint directly. The enabled route exposes these existing CLI semantics.

      Trust Boundaries and Controls

      • observed — The RPC requires orchestration-read authorization and retains the existing routing wrapper. Hostless references must match the selected project's repository; hosted references require an available workspace route on the host. The service derives the execution directory from that route rather than accepting it from the caller.
      • observed — Caller-provided commits must be hexadecimal SHA abbreviations or full hashes. Repository names, file paths, and revision query values are URL-encoded, and the operation passes structured arguments to glab for repository API reads rather than using file paths for local filesystem access.

      Resilience and Maintainability Implications

      • observed — Each file read has a 1 MiB output limit and 60-second timeout. Truncated, NUL-containing, or invalid-UTF-8 results fail instead of being returned as complete text. The operation constructs its result only after both applicable reads succeed and introduces no persistent state transition requiring rollback or recovery.




      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly and concisely describes the primary change: enabling GitLab merge requests to expand unchanged lines.
      Description checkPassedThe description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, linked triage context, test results, manual verification, l…


      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR




      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

Sign in to join this conversation.