Truncate files which are too long
kunaltyagi opened this issue · comments
/opt/github/actions-runner-1/_work/_actions/peter-evans/create-or-update-comment/v3.0.0/dist/index.js:4685
const error = new requestError.RequestError(toErrorMessage(data), status, {
^
RequestError [HttpError]: Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"}
at /opt/github/actions-runner-1/_work/_actions/peter-evans/create-or-update-comment/v3.0.0/dist/index.js:4685:21
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
status: 422,
This is caused when the body-path
file is too large. Can we limit the body content to 65535 characters with a mode (head/tail)? This would limit an unexpected error handling if an additional warning was output when the file size if more than the limit
A prototype in shell:
if [ stat -c "%s" <file> -gt 65535 ]; then
echo "::warning file=${filename},line=1,endLine=1,title=Content too long::Restricting content to just 65535 bytes as per truncation setting: ${mode}"
# get extra bytes since unicode characters can be longer than 1 byte
if [ ${mode} == "tail" ]; then command=tail else command=head; fi
content=$(${command} -c 65538 ${filename} | iconv -c -f UTF-8 -t UTF-8 | ${command} -c 65535)
else
content=$(cat ${filename}
fi
Hi @kunaltyagi
Thank you for raising this issue.
I've made a fix for this in v3.0.1
/ v3
. The action will now truncate the body if it exceeds the max length.
You suggested options for head/tail, but I would rather not add those to the action. If you need more complex logic for truncation then that should be done in a separate workflow step before calling this action.