Skip to content

fix(gitlab): handle concatenated JSON pages from glab --paginate#717

Merged
backnotprop merged 1 commit into
mainfrom
fix/714
May 13, 2026
Merged

fix(gitlab): handle concatenated JSON pages from glab --paginate#717
backnotprop merged 1 commit into
mainfrom
fix/714

Conversation

@backnotprop
Copy link
Copy Markdown
Owner

Summary

  • glab api --paginate concatenates page responses as adjacent JSON arrays ([...][...]), which JSON.parse rejects. MR reviews failed with "JSON Parse error" on any MR with more than 100 changed files.
  • Replace the bare JSON.parse in parsePaginatedArray with a walker that splits the output into top-level arrays and merges them. The walker tracks string state and escape sequences so a literal ][ inside diff content is not mistaken for a page boundary.
  • Add focused unit tests covering single-page, multi-page merge, brackets inside strings, escaped quotes, empty input, and empty pages.

Fixes #714

Test plan

  • bun test packages/shared/pr-gitlab.test.ts — 7/7 pass
  • bun test packages/shared/pr-provider.test.ts packages/shared/pr-gitlab.test.ts — 25/25 pass, no regressions
  • Manual: open a GitLab MR with >100 changed files and verify the diff loads

glab api --paginate joins page responses as adjacent JSON arrays
(`[...][...]`), which JSON.parse rejects. This caused MR reviews to fail
with "JSON Parse error" for any MR with more than 100 changed files.

Replace the bare JSON.parse with a walker that splits the output into
top-level arrays (string- and depth-aware so `][` inside diff content
is not mistaken for a page boundary) and merges them.

Fixes #714
@backnotprop backnotprop merged commit 927ca6d into main May 13, 2026
10 checks passed
@backnotprop backnotprop deleted the fix/714 branch May 13, 2026 12:33
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: glab api --paginate produces invalid JSON, causing "JSON Parse error" on large MRs

1 participant