Skip to content

[SPN-2931] Truncate oasdiff changelog to fit GitHub's 64-KB PR body limit#30

Merged
drago1216 merged 1 commit into
mainfrom
aaronbarnes/SPN-2931-pr-body-truncate
Jun 1, 2026
Merged

[SPN-2931] Truncate oasdiff changelog to fit GitHub's 64-KB PR body limit#30
drago1216 merged 1 commit into
mainfrom
aaronbarnes/SPN-2931-pr-body-truncate

Conversation

@drago1216

Copy link
Copy Markdown
Contributor

Summary

Mirror of bhr-api-php#83's changelog-truncation fix. Both repos' `build_pr_body.py` started as verbatim copies and share the same latent bug: the full oasdiff markdown changelog is inlined into the PR body unconditionally, and a major spec rewrite (e.g. PR #23's 863 ERR-level breaking changes, ~100 KB of markdown) blows past GitHub's hard 65,536-char PR body limit.

The PHP repo hit this first; ours hasn't reproduced yet but would on the next big-diff run.

Fix

Size-budget the changelog. Build all other sections optimistically, treat their total length as fixed cost, give the changelog whatever budget is left under `SAFE_BUDGET = 60_000` chars.

When the changelog overflows:

  • `truncate_at_line()` slices on a line boundary so we never cut mid-line
  • a notice appended at the end with the run URL points reviewers at `.sdk-update/analysis/changelog.md` in the workflow run

`build_pr_body.py` gained a `--run-url` flag; the workflow passes `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`.

Verified locally with a synthetic 120K-char changelog: output lands at ~60K chars, line-aligned, all downstream sections intact.

Test plan

  • Trigger `sdk-update.yml` against a large-delta spec and confirm `gh pr create/edit` succeeds and the truncation notice links back to the run.

🤖 Generated with Claude Code

…imit

Mirror of bhr-api-php#83's fix. Our build_pr_body.py and sdk-update.yml
have the same shape (Python and PHP scripts started as a verbatim copy
of each other) and have the same latent bug: build_pr_body.py
unconditionally inlines the full oasdiff markdown changelog into the
PR body, and a major spec rewrite (e.g. PR #23's 863 ERR-level breaking
changes, ~100 KB of markdown) exceeds GitHub's hard 65,536-char PR
body cap.

The PHP repo hit it first because their workflow happened to trigger
against the latest spec; ours hasn't reproduced yet, but would the
next time the upstream spec has more than ~50 endpoint changes.

Fix: size-budget the changelog section. Build all other sections
optimistically, treat their total length as fixed cost, give the
changelog whatever budget is left under SAFE_BUDGET = 60,000 chars
(under the 65,536 hard cap, with headroom for joins, trailing
newlines, and gh's GraphQL serialization).

When the changelog overflows the available budget:
  - truncate_at_line() slices on a line boundary so we never cut
    mid-line
  - append a notice with the run URL so reviewers can find the full
    changelog at .sdk-update/analysis/changelog.md in the workflow run

build_pr_body.py gained a --run-url flag. The workflow passes
  ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
through an env var.

Verified locally (the PHP commit) with a synthetic 120K-char
changelog: output lands at ~60K, line-aligned, all downstream
sections intact.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drago1216 drago1216 requested a review from a team as a code owner June 1, 2026 20:45
@drago1216 drago1216 merged commit 3d4de06 into main Jun 1, 2026
5 checks passed
@drago1216 drago1216 deleted the aaronbarnes/SPN-2931-pr-body-truncate branch June 1, 2026 20:56
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