fix: output the actual PR comment in comment-content#1066
fix: output the actual PR comment in comment-content#1066jantiebot wants to merge 2 commits intoactions:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns the comment-content action output with the actual PR comment body that will be posted, including the existing “too large” fallbacks, so downstream workflow steps can safely reuse a postable comment.
Changes:
- Move
comment-contentoutput assignment to occur afterhandleLargeSummary()and theMAX_COMMENT_LENGTHfallback logic. - Update the compiled
dist/index.jsto reflect the same behavior.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main.ts | Sets comment-content to the final rendered comment (after truncation/min-summary fallback). |
| dist/index.js | Mirrors the same comment-content output behavior in the built distribution file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // PR comment/summary handling | ||
| let rendered = core.summary.stringify() |
There was a problem hiding this comment.
The comment "include full summary in output" is now misleading: comment-content is no longer set to the full core.summary.stringify() result, but to the post-processed rendered value after handleLargeSummary and the MAX_COMMENT_LENGTH fallback. Please update or remove this comment to match the new behavior.
| // Set the actual PR comment as output (minimal version if too large for a comment on GitHub) | ||
| core.setOutput('comment-content', rendered) | ||
|
|
There was a problem hiding this comment.
The behavior of the comment-content output changed (it now reflects the final PR comment after truncation/minimal fallback). There doesn't appear to be test coverage asserting which string is emitted via core.setOutput('comment-content', ...) for oversized summaries; consider extracting the "final rendered comment" selection into a small helper and adding unit tests for the normal / >1MB / >MAX_COMMENT_LENGTH paths to prevent regressions.
This is either a small bug or a documentation issue, based on the name of output I would consider this a bug however.
The documentation states that the
comment-contentoutput should contain the same content as the comment. However the action has a fail-safe to prevent large comments (which can happen often when the OpenSSF scorecard is enabled) and falls back to a minimum comment. Currently thecomment-contentoutput always contains the full comment/summary.This change fixes that by ensuring the
comment-contentoutput is set to the actual PR comment that this action would post (based on thecomment-summary-in-prinput).My use-case
As I'm using the
comment-contentoutput to post a comment in a later step myself, it's hard to process when the comment is large. E.g. when using the output as an env var input in another step I frequently see errors such as:Error: An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ubuntu/_work/xxxx/xxxx'. Argument list too longWhich I think happens because the kernel's
ARG_MAXis exceeded.I just want to be able to access an actual postable comment so for me this works best. I hope you agree. :)
If you believe the full summary should be available as an output as well I would suggest adding another output called
summary-contentor similar.