GitLab MR auto-merge check uses invalid glab mr view --json <fields> flag #274
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The MR stage's GitLab merge poller fails immediately when checking mergeability, aborting the run with
agent-failure:This happens on the deterministic (non-LLM) auto-merge polling path in runMrStage, so any GitLab run with autoMerge.enabled: true that reaches the mr stage fails at the very first mergeability check.
Root cause
GitLabMergePoller.isMergeable() in src/mr/services/gitlabMergePoller.ts calls:
This models glab's JSON flag on GitHub CLI's
gh pr view --json <fields>syntax (comma-separated field selection). glab mr view has never supported this. Checked the full glab (gitlab-org/cli) tag history, v1.0.0 to v1.113.0:-F, --output string-> "Format output as: text, json" - a format toggle, not a field selector. It always dumps the whole MR object; there is no field1,field2 syntax.--jq <expr>flag to filter the full JSON client-side, e.g.glab mr view 5 -F json --jq '.merge_when_pipeline_succeeds'.No released version of glab supports
--json <fields>. Upgrading the CLI will not fix this - the flag needs to change.Also note: GitLab's JSON output uses snake_case field names (merge_when_pipeline_succeeds, has_conflicts), not the camelCase (mergeWhenPipelineSucceeds, hasConflicts) the parsing code in isMergeable() currently expects (RawGitLabMergeState interface) - this needs to be fixed at the same time or the check will silently always return the "not mergeable" branch.
Fix
In src/mr/services/gitlabMergePoller.ts, isMergeable():
glab mr view <n> -F json(optionally combine with --jq to pre-shape the object if only on glab >= v1.100.0 - but plain -F json + client-side parsing is safer and doesn't pin a minimum CLI version).Affected files
Acceptance criteria
glab mr view --json <fields>flag #279pi-loop opened and merged a pull request for this issue: #279