Skip to content

The PR comment body can exceed GitHub's size limit, and half of it is a false diagnostic #2

Description

@mairas

From the review on PR #1: #1 (comment)

render_comment caps the body by dropping diffs when the full render exceeds 60000 characters, then returns the diff-free body without measuring it. That body grows with entry count, so it crosses GitHub's 65536-character limit and the POST fails with HTTP 422 — no comment at all, on a red gate whose explanation is exactly what the comment carries.

Measured by two reviewers independently: 68836 characters at 50 stale pages × 9 locales, 274045 at 200; binary search puts the crossover at 82 source pages × 9 locales (738 entries, 66117 characters). halpi2 at 20 × 9 renders 26–34k, roughly 2× headroom. The fallback is reached precisely when a repository is furthest behind — a new consumer, or a locale added to mkdocs.yml, marks every page missing at once.

Compounding it, roughly half the fallback body is a false diagnostic. render_markdown reads a falsy diff as proof the blob was unreachable and emits <!-- page: stamped blob not in this clone; CI needs fetch-depth: 0 -->; the fallback manufactures exactly that by rebuilding entries without diffs. On a full clone where every blob was present: 1800 of 1800 entries carried the notice, 138600 of 274027 bytes.

Fix: measure the fallback too and truncate the table when it would still exceed the ceiling, naming how many entries were dropped and pointing at the job summary. Separately, give Entry an explicit signal for "diff not computed" distinct from "diff could not be computed", so the fetch-depth hint appears only when english_diff actually failed.

Test: the existing guard cannot fail — test_an_oversized_body_drops_the_diffs_and_points_at_the_summary builds a two-row fallback, so assert len(out) < 65536 holds by construction. Replace it with a wide tree (200 pages stale in every locale) asserting the emitted body is under the ceiling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions