Compare commits

...
Author SHA1 Message Date
paseo-bot[bot] 9f9982b488 fix(gitlab): resolve merge requests with legacy null references
Successful legacy MR responses were rejected before branch status could be resolved. Accept null at the existing response boundary, as with absent reference metadata, while keeping current response validation.
2026-10-10 13:03:59 +02:00
2 changed files with 30 additions and 1 deletions
@@ -298,6 +298,35 @@ describe("createGitLabService", () => {
expect(calls[1]).toEqual(["mr", "view", "14", "-F", "json"]);
});
it.each(["list", "view"])(
"resolves the current merge request when %s returns legacy null references",
async (legacyCommand) => {
const legacyMr = {
...OPEN_MR,
reference: "!14",
references: null,
web_url: "https://gitlab.example.com/example-group/example-project/merge_requests/14",
};
const { service } = makeService((args) => {
const mr = args[1] === legacyCommand ? legacyMr : OPEN_MR;
if (args[0] === "mr" && args[1] === "list") return ok(JSON.stringify([mr]));
if (args[0] === "mr" && args[1] === "view") return ok(JSON.stringify(mr));
if (args[0] === "api") return ok("{}");
throw new Error(`unexpected call: ${args.join(" ")}`);
});
await expect(
service.getCurrentPullRequestStatus({ cwd: "/repo", headRef: "release/v0.4.0" }),
).resolves.toMatchObject({
number: 14,
title: OPEN_MR.title,
state: "open",
headRefName: "release/v0.4.0",
url: legacyCommand === "view" ? legacyMr.web_url : OPEN_MR.web_url,
});
},
);
it("reports a conflicting merge request as CONFLICTING", async () => {
const conflicting = {
...OPEN_MR,
@@ -168,7 +168,7 @@ const GitLabMergeRequestSchema = z
description: z.string().nullable().optional(),
labels: z.array(z.string()).optional(),
updated_at: z.string().optional(),
references: z.object({ full: z.string().optional() }).passthrough().optional(),
references: z.object({ full: z.string().optional() }).passthrough().nullable().optional(),
head_pipeline: GitLabPipelineSchema.nullable().optional(),
})
.passthrough();