Skip to content

Conversation

@rmainwork
Copy link
Contributor

@rmainwork rmainwork commented May 5, 2025

πŸ”— Relevant links

πŸ—’οΈ What

Set a configurable char limit on broken link reports.

🀷 Why

This is to avoid a limitation in the GH API preventing the creation of a PR comment with a body longer than 65536 characters. Attempting to do so (as can happen when there are a lot of broken links) produces the following error:

Error: Validation Failed: {"resource":"IssueComment","code":"unprocessable","field":"data","message":"Body is too long (maximum is 65536 characters)"}

πŸ› οΈ How

πŸ§ͺ Testing

A PR has been opened against this branch (rm/lychee-results-to-gh-artifacts) to test this without merging into main. That PR has a large number of files changed and the links intentionally broken, so that the char length of the report exceeds the maximum char limit(configurable as a variable here). Looking at that PR, we can see that the full report has been uploaded to GH artifacts and a link posted as a PR comment instead

image

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2025

Vercel Previews Deployed

Name Status Preview Updated (UTC)
Dev Portal βœ… Ready (Inspect) Visit Preview Thu May 8 19:50:04 UTC 2025
Unified Docs API βœ… Ready (Inspect) Visit Preview Thu May 8 19:45:58 UTC 2025

@rmainwork rmainwork force-pushed the rm/lychee-results-to-gh-artifacts branch 7 times, most recently from 7f5c4ab to 2ef0916 Compare May 6, 2025 19:55
@hashicorp hashicorp deleted a comment from github-actions bot May 6, 2025
@rmainwork rmainwork force-pushed the rm/lychee-results-to-gh-artifacts branch 3 times, most recently from 6701a80 to c1a927e Compare May 6, 2025 20:40
rmainwork added 2 commits May 7, 2025 10:09
Checks the char count of the lychee broken link report prior to
attaching to the PR. This is to help avoid a scenario where the report
hits the 65536 char max count of the GH API
This allows us more flexibility to adjust the max length in the future
without doing a find-and-replace accross the workflow file
@rmainwork rmainwork force-pushed the rm/lychee-results-to-gh-artifacts branch from c1a927e to b383d73 Compare May 7, 2025 14:09
This compares the char count to the action variable numerically (integer to
integer) rather than lexicographically. In this case, the report char count was
'1209122' which is _technically_ greater than 65536(the configured max), but
since the values were being compared lexicographically, and the string '1209122'
begins with a 1, this expression was evaluating to '1209122' >= '65536'(since
'1209122' begins with a 1).
@rmainwork rmainwork force-pushed the rm/lychee-results-to-gh-artifacts branch from 4fe0f33 to e719427 Compare May 7, 2025 18:31
@rmainwork rmainwork changed the title [WIP] Upload lychee results to GH artifacts for excessively long reports Upload lychee results to GH artifacts for excessively long reports May 7, 2025
@rmainwork rmainwork marked this pull request as ready for review May 7, 2025 18:35
@rmainwork rmainwork requested a review from a team as a code owner May 7, 2025 18:35
@rmainwork rmainwork requested a review from RubenSandwich May 7, 2025 18:35
Copy link
Contributor

@RubenSandwich RubenSandwich left a comment

Choose a reason for hiding this comment

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

rmainwork added 2 commits May 8, 2025 15:37
"Download full report" is a more actionable sentence than "See <link>
for full report"
@rmainwork rmainwork requested a review from RubenSandwich May 8, 2025 19:42
Copy link
Contributor

@RubenSandwich RubenSandwich left a comment

Choose a reason for hiding this comment

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

πŸ‘πŸ»

@rmainwork rmainwork merged commit 420cc9d into main May 8, 2025
9 checks passed
@rmainwork rmainwork deleted the rm/lychee-results-to-gh-artifacts branch May 8, 2025 19:52
hashibot-web added a commit that referenced this pull request Sep 5, 2025
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