Skip to content

actions: pin /review URLs to the immutable base commit SHA#117

Open
reuvenharrison wants to merge 1 commit into
mainfrom
fix/review-url-immutable-base-sha
Open

actions: pin /review URLs to the immutable base commit SHA#117
reuvenharrison wants to merge 1 commit into
mainfrom
fix/review-url-immutable-base-sha

Conversation

@reuvenharrison
Copy link
Copy Markdown
Contributor

@reuvenharrison reuvenharrison commented May 21, 2026

Summary

The free /review URL emitted by breaking, changelog, and pr-comment used $GITHUB_BASE_REF (the branch name, e.g. main) in the base_sha query parameter. That's mutable — once the base branch advances past the commit the action ran against, every previously-emitted URL silently breaks. raw.githubusercontent.com resolves the branch to whatever HEAD is now, not what HEAD was when CI ran. The rev_sha parameter was already pinned to the immutable head commit; base_sha was not.

Concrete failure mode: a workflow runs, emits a ::notice:: link with base_sha=main&base_file=backend/openapi.json. Later, another PR merges a rename of that file. The original ::notice:: link now 404s on the base side, and the visitor can't tell whether the cause is a permissions problem or a moved file. So they chase the wrong fix.

Fix

Three-tier fallback for base_sha in all three URL-emitting entrypoints:

  1. pull_request.base.sha from $GITHUB_EVENT_PATH (canonical for pull_request triggers)
  2. git rev-parse origin/$GITHUB_BASE_REF (push triggers that have fetched the base branch)
  3. $GITHUB_BASE_REF (ultimate fallback — today's behavior)

pr-comment already used #1 with #3 as fallback; this PR adds #2 to its chain. breaking and changelog gain the whole chain. head_sha extraction is unchanged.

Test plan

  • bash -n syntax check on all three entrypoints
  • Existing integration tests pass (the test workflow exercises the actions end-to-end)
  • After merge, watch a real PR run and confirm the emitted ::notice:: link contains a 40-char SHA in the base_sha= position, not a branch name

Backward compatibility

Strict superset of today's contract. Worst case (no pull_request.base.sha available, git rev-parse fails) falls back to $GITHUB_BASE_REF, which is today's behavior. URLs already in the wild keep working at the same URLs they pointed at before; the change affects only newly-emitted URLs from this version forward.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Generated with Claude Code

The free /review URL emitted by every entrypoint used $GITHUB_BASE_REF
(the branch name, e.g. "main") in the base_sha query parameter. That's
mutable: once the base branch advances past the commit the action ran
against — for example, when a downstream PR renames or moves the spec
file on main — every previously-emitted /review URL silently breaks.
raw.githubusercontent.com resolves the branch to whatever the current
HEAD is, not what HEAD was when CI ran. The rev_sha parameter was
always pinned to the immutable head commit, but base_sha wasn't,
leaving the base side of every URL exposed to drift.

Switch all three URL-emitting entrypoints (breaking, changelog,
pr-comment) to a three-tier fallback for base_sha:

  1. pull_request.base.sha from $GITHUB_EVENT_PATH (the canonical
     value for pull_request triggers)
  2. git rev-parse origin/$GITHUB_BASE_REF (works on push triggers
     where the base branch was fetched into the workspace)
  3. $GITHUB_BASE_REF as the ultimate fallback (today's behavior,
     so this is a strict superset of the current contract)

The pr-comment entrypoint already used pattern #1 with #3 as fallback;
this commit adds #2 to its chain so push triggers also get an
immutable SHA whenever possible. breaking and changelog gain the
whole chain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@reuvenharrison reuvenharrison force-pushed the fix/review-url-immutable-base-sha branch from f7ff8f2 to 74f141d Compare May 21, 2026 21:37
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.

1 participant