Skip to content

chore: harden highlights comment posting against API/size failures - #306

Merged
mmcky merged 2 commits into
mainfrom
chore/harden-highlights-comment
May 21, 2026
Merged

mmcky merged 2 commits into
mainfrom
chore/harden-highlights-comment

Conversation

@mmcky

@mmcky mmcky commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #305 addressing Copilot's review feedback — the createComment call posting highlights.md wasn't wrapped in error handling and didn't account for GitHub's 65,536-char comment body limit.

Changes

Two hardening tweaks in the github-script step:

  1. Body-size truncation. If highlights.md exceeds 65,536 chars, truncate to fit and append a footer linking to the workflow run's artifact bundle so the full content remains recoverable. Today's highlights run ~10K chars; this is preventive against a busy month + LLM narratives + many translation-sync PRs growing the output.

  2. try / catch around createComment. Transient API failures (rate limits, network blips) now log to stderr and let the workflow finish green. Rationale: the report issue is already created by the time we reach the comment step, so the report itself is preserved regardless of what happens to the comment. highlights.md is also in the uploaded artifact, so the highlights are manually recoverable.

Net effect

Scenario Before After
Comment under 65K chars, API healthy Posts comment ✅ Posts comment ✅
Comment over 65K chars Workflow fails red Posts truncated comment + artifact link ✅
Transient API failure on createComment Workflow fails red Logs error, run goes green; issue still created, artifact still uploaded ✅

Test plan

  • Merge
  • Manually trigger the workflow via workflow_dispatch once
  • Confirm the highlights comment posts as before (size-truncation path won't trigger on the current report size, but the try/catch path is exercised on the happy path too)

🤖 Generated with Claude Code

Addresses Copilot's feedback on #305: the createComment call could
fail (oversize body, transient API error, rate limit) and crash the
whole workflow even though the report issue has already been created.

Two hardening changes:

1. Body-size truncation. GitHub caps issue comments at 65,536 chars.
   Today's highlights run at ~10K chars, well below the limit, but a
   busy month with --llm-summary across many translation-sync PRs
   could grow. If highlights.md exceeds the limit, truncate to fit
   and append a footer linking to the workflow run's artifact so the
   full content is recoverable.

2. try/catch around createComment. Transient API failures now log
   to stderr and continue rather than failing the step. Rationale:
   the report issue was already created in the preceding lines, so
   the report is preserved regardless of what happens to the
   comment. highlights.md is also in the uploaded artifact bundle,
   so the highlights themselves are recoverable manually.

Net effect: the workflow now degrades gracefully on any
comment-posting failure mode rather than turning red.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Hardens the weekly report workflow’s highlights comment posting to avoid workflow failures due to GitHub comment size limits and transient API errors, while keeping the full highlights accessible via artifacts.

Changes:

  • Truncates highlights.md to fit GitHub’s 65,536-character issue comment limit and appends a footer linking to the workflow run.
  • Wraps issues.createComment in a try/catch to prevent transient comment-posting failures from failing the workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/weekly-report.yml Resolved
Comment thread .github/workflows/weekly-report.yml Resolved
Two follow-up tweaks both flagged on the inline review:

1. Wrap fs.readFileSync('highlights.md') in its own try/catch.
   existsSync doesn't guarantee the read succeeds (permission/IO
   errors are theoretically possible even on a fresh CI runner), and
   the asymmetry with the weekly-report.md read above was a smell.
   On read failure: log + null out and skip the comment path —
   behaves identically to "file not produced".

2. Log richer fields when createComment fails. Octokit errors carry
   .status and .response.data with the actual diagnostic, while
   .message is often terse ("Validation Failed"). The catch block
   now logs the HTTP status when present, falls back to String(err)
   if .message is missing, and appends response.data when available.
   Future debugging won't be limited to the bare .message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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