Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions actions/setup/js/safe_outputs_handlers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ function buildIntentErrorResponse(error) {
*/
function hasUpdatePullRequestFields(args) {
const safeArgs = args || {};
return (
typeof safeArgs.title === "string" ||
typeof safeArgs.body === "string" ||
safeArgs.update_branch === true
);
return typeof safeArgs.title === "string" || typeof safeArgs.body === "string" || safeArgs.update_branch === true;
}

/**
Expand Down
40 changes: 10 additions & 30 deletions actions/setup/js/safe_outputs_handlers.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,76 +1776,56 @@ describe("safe_outputs_handlers", () => {
});

it("should throw MCP error when called with null/undefined args", () => {
expect(() => handlers.updatePullRequestHandler(null)).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler(undefined)).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler(null)).toThrow(expect.objectContaining({ code: -32602 }));
expect(() => handlers.updatePullRequestHandler(undefined)).toThrow(expect.objectContaining({ code: -32602 }));
});

it("should throw MCP error when update_branch is explicitly false and no other fields", () => {
expect(() => handlers.updatePullRequestHandler({ update_branch: false })).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler({ update_branch: false })).toThrow(expect.objectContaining({ code: -32602 }));
});

it("should throw MCP error when title is null", () => {
expect(() => handlers.updatePullRequestHandler({ title: null })).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler({ title: null })).toThrow(expect.objectContaining({ code: -32602 }));
});

it("should throw MCP error when body is null", () => {
expect(() => handlers.updatePullRequestHandler({ body: null })).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler({ body: null })).toThrow(expect.objectContaining({ code: -32602 }));
});

it("should throw MCP error when update_branch is null", () => {
expect(() => handlers.updatePullRequestHandler({ update_branch: null })).toThrow(
expect.objectContaining({ code: -32602 })
);
expect(() => handlers.updatePullRequestHandler({ update_branch: null })).toThrow(expect.objectContaining({ code: -32602 }));
});

it("should write entry and return success when title is provided", () => {
const result = handlers.updatePullRequestHandler({ title: "New Title" });
expect(result).toHaveProperty("content");
const data = JSON.parse(result.content[0].text);
expect(data.result).toBe("success");
expect(mockAppendSafeOutput).toHaveBeenCalledWith(
expect.objectContaining({ type: "update_pull_request", title: "New Title" })
);
expect(mockAppendSafeOutput).toHaveBeenCalledWith(expect.objectContaining({ type: "update_pull_request", title: "New Title" }));
});

it("should write entry and return success when body is provided", () => {
const result = handlers.updatePullRequestHandler({ body: "Updated body" });
expect(result).toHaveProperty("content");
const data = JSON.parse(result.content[0].text);
expect(data.result).toBe("success");
expect(mockAppendSafeOutput).toHaveBeenCalledWith(
expect.objectContaining({ type: "update_pull_request", body: "Updated body" })
);
expect(mockAppendSafeOutput).toHaveBeenCalledWith(expect.objectContaining({ type: "update_pull_request", body: "Updated body" }));
});

it("should write entry and return success when update_branch is true", () => {
const result = handlers.updatePullRequestHandler({ update_branch: true });
expect(result).toHaveProperty("content");
const data = JSON.parse(result.content[0].text);
expect(data.result).toBe("success");
expect(mockAppendSafeOutput).toHaveBeenCalledWith(
expect.objectContaining({ type: "update_pull_request", update_branch: true })
);
expect(mockAppendSafeOutput).toHaveBeenCalledWith(expect.objectContaining({ type: "update_pull_request", update_branch: true }));
});

it("should write entry and return success when both title and body are provided", () => {
const result = handlers.updatePullRequestHandler({ title: "New Title", body: "New body" });
expect(result).toHaveProperty("content");
const data = JSON.parse(result.content[0].text);
expect(data.result).toBe("success");
expect(mockAppendSafeOutput).toHaveBeenCalledWith(
expect.objectContaining({ type: "update_pull_request", title: "New Title", body: "New body" })
);
expect(mockAppendSafeOutput).toHaveBeenCalledWith(expect.objectContaining({ type: "update_pull_request", title: "New Title", body: "New body" }));
});

it("error message should mention all required fields", () => {
Expand Down
9 changes: 0 additions & 9 deletions actions/setup/js/safe_outputs_tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,6 @@
},
{
"name": "update_pull_request",

"description": "Update an existing GitHub pull request's title or body. Supports replacing, appending to, or prepending content to the body. Title is always replaced. Only the fields you specify will be updated; other fields remain unchanged. REQUIRED: You must provide at least one of: 'title' (a non-empty string), 'body' (a string), or 'update_branch' set to true (not false). Omitting all three, or passing only 'update_branch: false', will return a -32602 error.",
"inputSchema": {
"type": "object",
Expand Down Expand Up @@ -846,14 +845,6 @@
"description": "Trustworthiness level of the message source (e.g., \"low\", \"medium\", \"high\")."
}
},
"anyOf": [
{ "required": ["title"] },
{ "required": ["body"] },
{
"required": ["update_branch"],
"properties": { "update_branch": { "const": true } }
}
],
"additionalProperties": false
}
},
Expand Down
Loading