GitLab MR auto-merge check uses invalid glab mr view --json <fields> flag #273
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 withautoMerge.enabled: truethat reaches themrstage fails at the very first mergeability check.Root cause
GitLabMergePoller.isMergeable()insrc/mr/services/gitlabMergePoller.tscalls:This models
glab's JSON flag on GitHub CLI'sgh pr view --json <fields>syntax (comma-separated field selection).glab mr viewhas never supported this. Checked the fullglab(gitlab-org/cli) tag history, v1.0.0 → v1.113.0:893f5c94, "feat: Json output", 2024-03-07):mr viewhad no JSON output at all (text only).-F, --output string→Format output as: text, json— a format toggle, not a field selector. It always dumps the whole MR object; there is nofield1,field2syntax.--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
glabsupports--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 inisMergeable()currently expects (RawGitLabMergeStateinterface) — 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():--jqto pre-shape the object if only onglab >= v1.100.0— but plain-F json+ client-side parsing is safer and doesn't pin a minimum CLI version.)RawGitLabMergeStateand the parsing logic inisMergeable()to read the snake_case fields (merge_when_pipeline_succeeds,has_conflicts) from the full MR JSON object instead of the nonexistent filtered fields.src/mr/services/gitlabMergePoller.test.tsmocks/fixtures to match the new command args and snake_case JSON shape.Affected files
src/mr/services/gitlabMergePoller.tssrc/mr/services/gitlabMergePoller.test.tsAcceptance criteria
GitLabMergePoller.isMergeable()callsglab mr view <n> -F json(no unsupported--json <fields>flag).npm run lintandnpm testpass.glabinstall (or a fixture capturing realglab mr view -F jsonoutput) that the shape assumptions hold.