Report the gh error on a skipped apply, don't guess it - #52
Merged
Conversation
Two `gh: Upgrade to GitHub Pro ... (HTTP 403)` lines appeared in the 2026-09-06 rollout log looking like unexplained failures. They were the expected private-repo branch-protection skips, but neither the placement nor the wording said so. Neither `apply_branch_protection` nor `apply_ruleset` captured stderr, so gh's unbuffered output reached the log seconds ahead of the buffered SKIP line that explained it — and `gh_error`, which the ruleset handler already called, had nothing to report and fell back to a bare exit code. Capture stderr in both, and have the branch-protection skip print what GitHub actually said instead of asserting the plan limitation. A 403 from the token lacking Administration write is indistinguishable from here, and naming the wrong cause sends the reader down the wrong path. NO-ISSUE: log clarity, cause found while verifying the first release rollout Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgLE8cg9huy2EZnRoXhmwp
gavinbee
marked this pull request as ready for review
September 6, 2026 06:15
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.
What & why
The first release rollout (run 34010517658) logged two
gh: Upgrade to GitHub Pro or make this repository public to enable this feature. (HTTP 403)lines that read as unexplained failures. They were the expected private-repo branch-protection skips onofficials-adminandrems-sync-apps-script, but nothing at the point of the message said so.Two causes, one fix:
apply_branch_protectionnorapply_rulesetcaptured stderr. gh's stderr is unbuffered while Python's stdout is block-buffered when piped, so the raw 403 reached the log ~9 seconds ahead of all the=== repo ===headers — detached from theSKIPline that explained it.gh_errorhad nothing to work with. The ruleset handler already called it, but with stderr uncaptured it could only ever fall back to(exit 1). That path hasn't fired yet, so it would have bitten the first time a ruleset apply failed.Both now pass
stderr=subprocess.PIPE, and the branch-protection skip reports what GitHub actually said instead of asserting the cause. A 403 from the token lacking Administration write is indistinguishable from here, and naming the plan limitation for it would send the reader down the wrong path:gh_error's docstring now states that capturing stderr is part of its contract, since that is the invariant both call sites broke.Testing
ruff check .clean.pytest -q— 34 passed, 2 new.TestStderrIsCapturedcases were checked against the unfixed script and fail there (KeyError: 'stderr'), so they are not passing vacuously.Checklist
no-issueruff check .clean (Python repos)NO-ISSUE: log clarity, cause found while verifying the first release rollout
🤖 Generated with Claude Code