Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split GitHub comments into multiple comments if plan output is long #1645

Open
raouf-xh opened this issue Aug 1, 2024 · 3 comments
Open

Comments

@raouf-xh
Copy link
Contributor

raouf-xh commented Aug 1, 2024

GitHub has a max of 65,535 characters per comment. So in case of a long plan output, it is not sent to GitHub comment and throws an error within the Job

failed to report strategy: 
error while sending job comments error editing comment: PATCH https://api.github.com/repos/raouf-xh/terraform-test/issues/comments/xxxxx: 422 Validation Failed [{Resource:IssueComment Field:body Code:custom Message:body is too long (maximum is 65536 characters)}]
failed to report strategy: 
Warning: nil passed to plan result, sending empty
Failed to run commands. error while sending job comments error editing comment: PATCH https://api.github.com/repos/raouf-xh/terraform-test/issues/comments/xxxxx: 422 Validation Failed [{Resource:IssueComment Field:body Code:custom Message:body is too long (maximum is 65536 characters)}]
Error: Process completed with exit code 5.

Fix would be splitting the comment into multiple comments if it's over that size.

@agjendem
Copy link

agjendem commented Sep 30, 2024

I've got the same error message, we're running in no-backend: true mode and with 20+ workflows.

I can see that the comment is patched probably 2-3 times per workflow (each of the sections "Plan output", "Terraform plan validation check" and "Plan summary"?) so we actually end up with the later workflows being able to append their validation + plan summary (because they're still within the limit) but loose the Plan outputs, until all of them fail once the 64kb is filled up.

I've tried flipping the post-plans-as-one-comment but can't see that it has any effect in our setup, it's always a single comment. I'd be happy with splitting the comments per workspace as a solution for now.

Another possible way would be to be able to limit which of the sections that is written to the comment. In my case we would be happy with the Changes to Outputs: part of the Plan output rather than all of the lines with "Refreshing state..." for each of the resources (and if possible rather a link to easily jump to the complete log from the action?)

A third option would be to just splitting it into multiple comments as it is.

@motatoes
Copy link
Contributor

@agjendem it should be possible to configure split out comments using reporting-strategy: multiple_comments in the workflow file should make digger post multiple comments, if it does not work for you that needs to be investigated as well

@agjendem
Copy link

agjendem commented Oct 3, 2024

@agjendem it should be possible to configure split out comments using reporting-strategy: multiple_comments in the workflow file should make digger post multiple comments, if it does not work for you that needs to be investigated as well

Thanks @motatoes, that actually works for me! (Didn't notice the default value in the docs and had it set to latest_run_comment)

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

No branches or pull requests

3 participants