Skip to content

fix(gitlab): a merge request with a huge description no longer breaks the branch's MR lookup - #32758

Open
only21mil wants to merge 1 commit into
pingdotgg:mainfrom
only21mil:fix/gitlab-mr-list-output-cap
Open

only21mil wants to merge 1 commit into
pingdotgg:mainfrom
only21mil:fix/gitlab-mr-list-output-cap

Conversation

@only21mil

@only21mil only21mil commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On GitLab, T3 Code finds the current branch's merge request with glab mr list --source-branch <branch> --output json. glab returns every merge request's full description, and the command runs with the default 1,000,000-byte output cap. When one merge request's JSON passes that cap, the output is cut off and decoding fails with "GitLab CLI returned invalid MR list JSON". Renovate merge requests with long release notes are a realistic example.

Then the branch shows no merge request, and the create/open merge request action fails with that error instead of finding the existing one.

Change

GitLabCli.listMergeRequests now passes maxOutputBytes of 16 MiB. This is the same limit and constant name as #24215, which fixes the same cap for the Pull Requests page list in GitLabPullRequestCli, and the same limit as the Azure DevOps list (#8572). A new case in GitLabCli.test.ts returns one valid merge request whose JSON is over 1,000,000 bytes, truncating at the requested cap like the process runner does, and expects it to decode.

Scope and approval

A very small, focused fix for an obvious bug: one constant, one option on one call, one test. It does not touch GitLabPullRequestCli (#24215 covers that list) and does not change the process runner's default.

Related open PRs: #24215 is the sibling fix on the other GitLab list. #29791 rewrites this function to read 100 rows and retry a truncated page with smaller pages; a single merge request over the cap still fails there at one row per page, so the two changes work together. If #29791 lands first, this line moves into its execute call.

Verification

  • Failing test first, from packages/source-control-gitlab: vp test run src/server/GitLabCli.test.ts
    • On main: 1 failed | 5 passed, the new case fails with GitLabMergeRequestListDecodeError: GitLab CLI failed in listMergeRequests: GitLab CLI returned invalid MR list JSON.
    • With the fix: 6 passed, and 6 passed again with this branch merged locally with main 6a8f82c.
  • vp run check:changed on this branch merged locally with main 6a8f82c: format, lint, knip, typecheck (11 packages) and tests pass.
  • Real run: a throwaway self-hosted GitLab CE 19.5.4 in a local VM, a public project with one open merge request from renovate/all-minor-patch whose description is 1,019,968 bytes, and real glab 1.130.0, not signed in. I cloned it from that GitLab and added it in the web app (Browser panel; dev servers named "Test machine", empty test homes). Order: main 6a8f82c, this branch 0f73521, then this branch merged locally with main.

glab mr list for the branch prints 1,033,753 bytes, past the 1,000,000-byte cap (output below).

Before (main 6a8f82c): the branch's Git panel offers Create MR and shows no merge request.

Before, main 6a8f82ca7c: Create MR, no merge request shown

Before (main 6a8f82c): running Create MR fails with "GitLab CLI returned invalid MR list JSON."

Before, main 6a8f82ca7c: Action failed toast

After (this branch 0f73521): the same branch shows its merge request #1.

After, 0f735211d5: merge request #1 shown

After (this branch 0f73521 merged locally with main 6a8f82c): the same branch shows merge request #1.

After, 0f735211d5 merged with main 6a8f82ca7c: merge request #1 shown

glab output and server logs

glab, run in the project clone:

$ glab --version
glab 1.130.0 (9b430a11f)
$ glab mr list --source-branch renovate/all-minor-patch --per-page 20 --output json | wc -c
1033753
$ glab mr list --source-branch renovate/all-minor-patch --per-page 20 --output json | jq -c ".[] | {iid, state, source_branch, target_branch, description_bytes: (.description | utf8bytelength)}"
{"iid":1,"state":"opened","source_branch":"renovate/all-minor-patch","target_branch":"main","description_bytes":1019968}

Server log, main 6a8f82c:

[23:01:50.631] WARN (#2541) http.span=75136ms: PR lookup failed.
  operation: lookupStatusPr
  branch: renovate/all-minor-patch
  errorTag: SourceControlProviderError
  provider: gitlab
  providerOperation: listChangeRequests
  providerCommand: glab
  errorDetail: GitLab CLI returned invalid MR list JSON.
[23:02:21.159] WARN (#3413) http.span=105664ms: PR lookup failed.
  operation: lookupStatusPr
  branch: renovate/all-minor-patch
  errorTag: SourceControlProviderError
  provider: gitlab
  providerOperation: listChangeRequests
  providerCommand: glab
  errorDetail: GitLab CLI returned invalid MR list JSON.

Server log, this branch 0f73521:

$ grep -c 'PR lookup failed' server-head.log
0
$ grep -c 'invalid MR list JSON' server-head.log
0

Not checked: a signed-in glab; desktop and mobile (the fix is server-side, so they read the same status); glab mr view, which still uses the default cap for a single merge request; Bitbucket and Forgejo list paths; the merge request detail panel.

Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly

… the branch's MR lookup

`glab mr list --output json` returns every MR's full description, so one MR with a very long description pushed the output past the default 1 MB read cap, the JSON was cut off, and the list failed to decode.

The list now reads up to 16 MiB, the same limit pingdotgg#24215 gives GitLabPullRequestCli's list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 8, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 0f73521

Macroscope's review found this PR approvable — GitLab merge-request lookup now accepts up to 16 MiB of output so large descriptions do not break branch lookup. The increase is bounded and limited to this read-only operation, with existing timeout and query behavior unchanged.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

GitLab merge-request list commands now use a 16 MiB output limit instead of the process default. A test checks that a response with a 1.1-million-character description still returns MR 44 with state open.

Changes: GitLab merge-request listing

Layer / File(s) Summary
Merge-request list output limit
packages/source-control-gitlab/src/server/GitLabCli.ts, packages/source-control-gitlab/src/server/GitLabCli.test.ts
The list command passes a 16 MiB output limit to process execution. The test verifies that a response above the default 1,000,000-byte cap still returns MR 44 with state open.

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

Change: Bug fix

Possibly related issues

Possibly related PRs

  • pingdotgg/t3code#24464: Raises the output limit for GitLab merge-request listing on an overlapping list path.
  • pingdotgg/t3code#24215: Applies the same output-limit change and adds a test for an oversized GitLab list response.

Suggested labels: bugfix, size:XS

Suggested reviewers: walshydev, macroscopeapp

Merge Risk: Minimal · up to 0f735

The larger output limit addresses the reported failure to find a merge request with a long description. No issue requiring a fix before merge was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix, the scope (GitLab), and the trigger (a merge request with a huge description). It matches the change, which raises the output cap for the MR list call so the branch's MR looku…
Linked Issues check Passed The only linked issue, #8572, is closed and completed. Under the assessment rules, it supplies historical context only, and no active directly linked targets remain. No linked-issue coding requirement…
Out of Scope Changes check Passed Whole-PR diff (merge base to reviewed head) touches two files only. GitLabCli.ts adds one constant with a comment and one maxOutputBytes option on the listMergeRequests process call. `GitLabCli.…
Description check Passed The description is thorough and follows the template's main sections. Problem, Change, Scope and approval, and Verification are all filled in with specifics. The Problem section gives the failing comm…
Full details: Title check

Explanation

The title names the fix, the scope (GitLab), and the trigger (a merge request with a huge description). It matches the change, which raises the output cap for the MR list call so the branch's MR lookup no longer fails on large descriptions. The title is not vague.

Full details: Linked Issues check

Explanation

The only linked issue, #8572, is closed and completed. Under the assessment rules, it supplies historical context only, and no active directly linked targets remain. No linked-issue coding requirements apply to this PR. The PR's own stated objective (raise the GitLabCli.listMergeRequests output cap so that a long MR description does not truncate glab mr list JSON) is implemented at the reviewed head: MERGE_REQUEST_LIST_MAX_OUTPUT_BYTES (16 MiB) is passed as maxOutputBytes to the list call in packages/source-control-gitlab/src/server/GitLabCli.ts. A regression test in GitLabCli.test.ts covers a valid MR list over 1,000,000 bytes. The test relies on a mocked process that truncates output at maxOutputBytes. This evidence supports the PR's own requirement, but #8572 does not add any requirement to it.

Full details: Out of Scope Changes check

Explanation

Whole-PR diff (merge base to reviewed head) touches two files only. GitLabCli.ts adds one constant with a comment and one maxOutputBytes option on the listMergeRequests process call. GitLabCli.test.ts adds one test case for that call. Both changes serve the single stated objective of the PR. The PR description states that GitLabPullRequestCli, the process runner default, and other list paths are not changed. The diff confirms that none of those files or paths are modified. No unrelated change was found.

Full details: Description check

Explanation

The description is thorough and follows the template's main sections. Problem, Change, Scope and approval, and Verification are all filled in with specifics. The Problem section gives the failing command, the cap, and the observed error. The Change section names the constant and the test. The Scope section explains why this is a small, focused fix of an obvious bug and links related PRs. Verification gives the failing-then-passing test run, the check:changed result, and a real GitLab run with before/after evidence. It also lists what was not checked. Two template points are only partly met. The Scope section does not link a triaged issue or maintainer approval. It argues the 'very small, focused fix of an obvious bug' exemption instead, which the template allows. The closing line about the model and harness is present. The description is complete enough to pass.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a9e709f and 0f73521.

Files selected for processing: 2

  • packages/source-control-gitlab/src/server/GitLabCli.test.ts
  • packages/source-control-gitlab/src/server/GitLabCli.ts

Limit details: You’ve used all 10 included reviews currently available.

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant