[SPN-2931] Truncate oasdiff changelog to fit GitHub's 64-KB PR body limit#30
Merged
Merged
Conversation
…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>
anderslyman
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
`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
🤖 Generated with Claude Code