Skip to content

fix: output the actual PR comment in comment-content#1066

Open
jantiebot wants to merge 2 commits intoactions:mainfrom
jantiebot:main
Open

fix: output the actual PR comment in comment-content#1066
jantiebot wants to merge 2 commits intoactions:mainfrom
jantiebot:main

Conversation

@jantiebot
Copy link
Copy Markdown
Contributor

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-content output 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 the comment-content output always contains the full comment/summary.

This change fixes that by ensuring the comment-content output is set to the actual PR comment that this action would post (based on the comment-summary-in-pr input).

My use-case

As I'm using the comment-content output 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 long
Which I think happens because the kernel's ARG_MAX is 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-content or similar.

@jantiebot jantiebot requested a review from a team as a code owner March 4, 2026 12:38
Copilot AI review requested due to automatic review settings March 4, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-content output assignment to occur after handleLargeSummary() and the MAX_COMMENT_LENGTH fallback logic.
  • Update the compiled dist/index.js to 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.

Comment on lines +245 to 246
// PR comment/summary handling
let rendered = core.summary.stringify()
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +259 to +261
// Set the actual PR comment as output (minimal version if too large for a comment on GitHub)
core.setOutput('comment-content', rendered)

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants