changelog/submit: stop routing fork PRs through the broken commit path#172
Open
cotti wants to merge 1 commit into
Open
changelog/submit: stop routing fork PRs through the broken commit path#172cotti wants to merge 1 commit into
cotti wants to merge 1 commit into
Conversation
Fork PRs from verified Elastic org members were silently falling into the commit-and-push branch of `changelog/submit/apply` and dying on `git push` with "fatal: You are not currently on a branch." Three defects compounded: 1. `changelog/submit/evaluate` shells `--can-commit "$CAN_COMMIT"` (and similar bool flags) into `docs-builder changelog prepare-artifact`. The underlying CLI framework (Nullean.Argh) treats `bool` as a presence-only switch — `--flag` sets true, omission leaves false. Passing `--can-commit "false"` therefore set `canCommit = TRUE` (the flag was present) and silently dropped the literal "false" as a stray positional. The artifact metadata then carried `can_commit: true` for every fork PR. 2. `changelog/submit/apply` trusted that metadata field alone to decide whether to commit. When `should-commit=true` came back incorrectly, the apply step checked out the fork at the head SHA (detached HEAD), tried to push to the upstream remote (where the GITHUB_TOKEN does have write but the branch doesn't exist), and failed hard. 3. There was no graceful fallback when the commit/push side failed; the workflow simply errored out, leaving the PR with no changelog comment either. Fixes: - `changelog/submit/evaluate/action.yml`: build the `prepare-artifact` argv as an array and append `--is-fork`, `--can-commit`, `--maintainer-can-modify` only when the upstream string value is exactly "true". This is forward-compatible with a later docs-builder change to `bool?` (which would add `--no-*` negations). - `changelog/submit/apply/action.yml`: add a defense-in-depth `is-fork != 'true'` guard to the checkout / validate-ref / commit steps. Even if `should-commit` ever flips to true incorrectly again, fork PRs will skip the commit path entirely and fall through to the existing comment-only logic instead of producing a confusing detached-HEAD error. - `changelog/submit/apply/action.yml`: mark the commit step `continue-on-error: true`, surface any failure via a workflow warning, and let the `Post comment-only changelog` step take over when `commit.outcome == 'failure'`. Same-repo PRs whose push is rejected (branch protection, revoked token scope, etc.) now preserve the generated entry as a PR comment instead of vanishing. The companion docs-builder change (switching the affected parameters to `bool?` and adding CLI-surface tests) ships separately. Co-authored-by: Cursor <cursoragent@cursor.com>
6 tasks
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
Fork PRs from verified Elastic org members (the only fork PRs that the workflow currently lets through) have been silently routed into the commit-and-push branch of
changelog/submit/applyand dying ongit pushwithfatal: You are not currently on a branch.Seeelastic/elastic-otel-java#1117's submit run for a concrete reproduction.Three defects compounded:
The CLI flag values are silently misread.
changelog/submit/evaluateshells--can-commit "$CAN_COMMIT"(and similar bool flags) intodocs-builder changelog prepare-artifact. The underlying CLI framework (Nullean.Argh) treatsboolas a presence-only switch:--flagsets true; omission leaves it false. Passing--can-commit "false"therefore setcanCommit = TRUE(the flag was present) and silently dropped the literal\"false\"as a stray positional. Confirmed against the:edgeimage'sprepare-artifact --help, which shows those three flags with no<value>placeholder unlike every string flag.The artifact metadata then carried
can_commit: truefor every fork PR from an org member.The apply step had no second line of defense. It trusted
should-commitalone, so whenshould-commit=truecame back incorrectly, it checked out the fork at the head SHA (detached HEAD), tried to push to the upstream remote (whereGITHUB_TOKENhas write but the branch doesn't exist), and failed hard.No graceful fallback on commit failure. The workflow errored out, leaving the PR with neither a committed entry nor a comment preview.
Changes
changelog/submit/evaluate/action.yml— build theprepare-artifactargv as an array and append--is-fork,--can-commit,--maintainer-can-modifyonly when the upstream string value is exactly\"true\". Forward-compatible with the planned docs-builder switch tobool?(which would also add--no-*negations).changelog/submit/apply/action.yml—is-fork != 'true'guard to the checkout / validate-ref / commit steps. Even ifshould-commitflips to true incorrectly again in the future, fork PRs will skip the commit path entirely and fall through to the comment-only logic instead of producing the detached-HEAD error. (See discussion of "fail closed on the next regression".)continue-on-error: true, surface any failure via a::warning::annotation, and let thePost comment-only changelogstep take over whencommit.outcome == 'failure'. Same-repo PRs whose push is rejected (branch protection, revoked token scope, etc.) now preserve the generated entry as a PR comment instead of vanishing.Companion PR
A separate docs-builder PR will switch the affected
prepare-artifactparameters tobool?so--can-commit falseis no longer ambiguous at the CLI surface, and adds the missing CLI-surface test that lets bool mishandling slip through today.Test plan
actionlint .github/workflows/changelog-*.yml,python3 -c \"import yaml; yaml.safe_load(open(...))\", andbash -non every inlinerun:block (done locally).changelog-submitworkflow against a fresh fork PR (e.g.elastic/elastic-otel-java) once this is merged + tagged: should post a single comment with the rendered entry and not attempt any commit/push.Related: #69, #129 (both about enabling fork-commit via PAT; this PR only restores the documented "forks always comment-only" path that was silently broken).
Made with Cursor