skip empty review submissions instead of posting noise
when create_pull_request_review is called with no body and no inline comments, return early with a clear log message instead of hitting GitHub's 422 or posting a useless "approved" comment. Made-with: Cursor
This commit is contained in:
committed by
pullfrog[bot]
parent
c6a3ee0e9a
commit
026cc7a276
@@ -146909,6 +146909,16 @@ function CreatePullRequestReviewTool(ctx) {
|
||||
execute: execute(async ({ pull_number, body, approved, commit_id, comments = [] }) => {
|
||||
if (body) body = fixDoubleEscapedString(body);
|
||||
ctx.toolState.issueNumber = pull_number;
|
||||
if (!body && comments.length === 0) {
|
||||
log.info(
|
||||
"review has no body and no inline comments \u2014 skipping submission (no issues found)"
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
skipped: true,
|
||||
reason: "no issues found \u2014 nothing to post"
|
||||
};
|
||||
}
|
||||
let event = approved ? "APPROVE" : "COMMENT";
|
||||
if (event === "APPROVE" && !ctx.prApproveEnabled) {
|
||||
log.info("prApproveEnabled is disabled \u2014 downgrading APPROVE to COMMENT");
|
||||
|
||||
@@ -84,6 +84,18 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) {
|
||||
// set issue context (PRs are issues)
|
||||
ctx.toolState.issueNumber = pull_number;
|
||||
|
||||
// skip empty reviews (no body, no inline comments) — nothing to post
|
||||
if (!body && comments.length === 0) {
|
||||
log.info(
|
||||
"review has no body and no inline comments — skipping submission (no issues found)"
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
skipped: true,
|
||||
reason: "no issues found — nothing to post",
|
||||
};
|
||||
}
|
||||
|
||||
// enforce prApproveEnabled: downgrade APPROVE to COMMENT if disabled
|
||||
let event: "APPROVE" | "COMMENT" = approved ? "APPROVE" : "COMMENT";
|
||||
if (event === "APPROVE" && !ctx.prApproveEnabled) {
|
||||
|
||||
Reference in New Issue
Block a user