Skip to content

Commit 284f54f

Browse files
authored
fix: truncate body if exceeds max length (#1915)
1 parent 9e5b234 commit 284f54f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

dist/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ function createPullRequest(inputs) {
334334
// Update the body input with the contents of the file
335335
inputs.body = utils.readFile(inputs.bodyPath);
336336
}
337+
// 65536 characters is the maximum allowed for the pull request body.
338+
if (inputs.body.length > 65536) {
339+
core.warning(`Pull request body is too long. Truncating to 65536 characters.`);
340+
inputs.body = inputs.body.substring(0, 65536);
341+
}
337342
// Get the repository path
338343
const repoPath = utils.getRepoPath(inputs.path);
339344
// Create a git command manager

src/create-pull-request.ts

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
4646
// Update the body input with the contents of the file
4747
inputs.body = utils.readFile(inputs.bodyPath)
4848
}
49+
// 65536 characters is the maximum allowed for the pull request body.
50+
if (inputs.body.length > 65536) {
51+
core.warning(
52+
`Pull request body is too long. Truncating to 65536 characters.`
53+
)
54+
inputs.body = inputs.body.substring(0, 65536)
55+
}
4956

5057
// Get the repository path
5158
const repoPath = utils.getRepoPath(inputs.path)

0 commit comments

Comments
 (0)