Repository navigation
Warn when sandbox_branch makes every github: directive a no-op - #134
Merged
Merged
Conversation
docs/testing-a-change.md told people to put the .asf.yaml under test on a `test/pr-<NNN>` branch and pass that as `sandbox_branch`. Doing so skips every directive under `github:`, which is most of what the sandbox exists to test, and the run exits 0 regardless -- so the workflow reports a pass having applied nothing at all. The gate is in feature/github/__init__.py, which returns early unless the branch being processed is the repository's default branch. `Repository.default_branch` derives that from a HEAD file in the directory it is given; bare repositories in production have one, the working tree actions/checkout produces does not, so the value falls back to the DEFAULT_BRANCH constant, `main`. A sandbox run therefore applies `github:` settings only when `sandbox_branch` is literally `main`, whatever the sandbox repository's own default branch is called. That is fixed here in the two places it misleads people rather than by changing the parser. Making `default_branch` fall back to the checked-out branch would let a feature branch apply repository settings when the parser is pointed at a working tree, which is a safety property worth keeping; if the gate itself should change, that is a separate discussion with a wider blast radius. So: the docs now say to put the configuration on the sandbox's `main`, and explain why, with the reset step rewritten around a `baseline` branch. The "Branch-scoped and repo-scoped settings behave differently" section said the opposite of what the code does -- that `github:` metadata "applies to the whole repo no matter which branch it was read from" -- and is replaced. The workflow now emits a warning annotation and a block in the run summary when `sandbox_branch` is not `main`, so a run that cannot prove anything says so where the result is read. Two related corrections while in these files: step 5 now says to read the setting back from the API rather than trust a green run, and step 7's example quotes before and after values. A directive whose state check is wrong prints its intent, exits 0 and changes nothing, which is indistinguishable from success unless you look. Generated-by: Claude Opus 5
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.
The problem
docs/testing-a-change.mdtells you to put the.asf.yamlunder test on atest/pr-<NNN>branch and pass that assandbox_branch. That skips every directiveunder
github:— which is most of what the sandbox exists to test — and the run exits0 anyway. The workflow reports a pass having applied nothing.
I hit this while testing seven open PRs and lost a while to it, which is the only reason
I noticed: the log line is easy to miss among the noop chatter, and nothing else about
the run looks wrong.
The gate is in
feature/github/__init__.py,which returns early unless the branch being processed is the repository's default branch.
Repository.default_branchderives that from aHEADfile in the directory it is handed —present in the bare repositories the parser sees in production, absent from the working
tree
actions/checkoutproduces — so it falls back to theDEFAULT_BRANCHconstant,main. A sandbox run therefore appliesgithub:settings only whensandbox_branchisliterally
main, regardless of what the sandbox repository's own default branch is called.Reproducible with no network and no token:
The docs also state the opposite of this outright, under "Branch-scoped and repo-scoped
settings behave differently":
What this changes
Docs. Step 2 puts the configuration on the sandbox's
mainand says why; step 3'stable and step 6's reset are rewritten around a
baselinebranch; the incorrect sectionabove is replaced with an accurate one that names the file, the constant and the fallback.
Workflow. A warning annotation and a block in the run summary when
sandbox_branchis not
main, so a run that cannot prove anything says so where the result is readrather than only in the log.
Skill. One line, so
.claude/skills/sandbox-test/SKILL.md(from #133) matches.What this deliberately does not change
The parser. Making
default_branchfall back to the checked-out branch would fix thesymptom, but it would also let a feature branch apply repository settings whenever the
parser is pointed at a working tree instead of a bare repo — a safety property worth
keeping. If the gate itself should be relaxed for testing, that deserves its own
discussion; this PR makes the existing behaviour visible instead of quietly wrong.
Testing
run:blocks shell-syntax checked, and the resolve step executed directlywith the workflow's own env:
sandbox_branch=mainis silent and setssandbox_branch_warning=no;sandbox_branch=test/pr-42emits the annotation and setsyes.run:block passesbash -n.poetry run pytest— 145 passed.poetry run pre-commit run --all-files— green.Add GitHub immutable releases #84, Fix: prevent_self_review breaks all environment creation via .asf.yaml #101, Add GitHub pull request creation cap support #111, Support changing or removing Jira autolinks #116, feat(github): add merge_queue convenience syntax for rulesets #119, Add restrict_update convenience key to prevent tags from being moved #120 and Add github.code_scanning for CodeQL default setup #122: configurations on
mainapplied, the sameconfigurations on a
test/branch did not.No parser code changes, so there is nothing here for the sandbox workflow itself to test.
🤖 Generated with Claude Code