Skip to content

Warn when sandbox_branch makes every github: directive a no-op - #134

Merged
Humbedooh merged 1 commit into
apache:mainfrom
potiuk:fix-sandbox-branch-gate
Sep 21, 2026
Merged

Humbedooh merged 1 commit into
apache:mainfrom
potiuk:fix-sandbox-branch-gate

Conversation

@potiuk

@potiuk potiuk commented Sep 18, 2026

Copy link
Copy Markdown
Member

The problem

docs/testing-a-change.md tells you to put the .asf.yaml under test on a
test/pr-<NNN> branch and pass that as sandbox_branch. That skips every directive
under github:
— which is most of what the sandbox exists to test — and the run exits
0 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.

[github] Saw GitHub meta-data in .asf.yaml, but not in default branch of repository, not updating...

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 handed —
present in the bare repositories the parser sees in production, absent from the working
tree actions/checkout produces — so it falls back to the DEFAULT_BRANCH constant,
main. A sandbox run therefore applies github: settings only when sandbox_branch is
literally main, regardless of what the sandbox repository's own default branch is called.

Reproducible with no network and no token:

$ asfyaml-run --repo .../infrastructure-asfyaml-sandbox --org me --branch test/pr-111 --noop --token dummy
[github] Saw GitHub meta-data in .asf.yaml, but not in default branch of repository, not updating...

The docs also state the opposite of this outright, under "Branch-scoped and repo-scoped
settings behave differently":

Repository metadata under github: is not branch-scoped: it applies to the whole repo
no matter which branch it was read from.

What this changes

Docs. Step 2 puts the configuration on the sandbox's main and says why; step 3's
table and step 6's reset are rewritten around a baseline branch; the incorrect section
above 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_branch
is not main, so a run that cannot prove anything says so where the result is read
rather 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_branch fall back to the checked-out branch would fix the
symptom, 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

No parser code changes, so there is nothing here for the sandbox workflow itself to test.

🤖 Generated with Claude Code

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
@Humbedooh
Humbedooh merged commit 8cafd8b into apache:main Sep 21, 2026
5 checks passed
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