Skip to content

ci: skip removed files in validate and review-hook workflows#587

Merged
marktoda merged 1 commit into
mainfrom
fix-workflows-removal-pr
May 27, 2026
Merged

ci: skip removed files in validate and review-hook workflows#587
marktoda merged 1 commit into
mainfrom
fix-workflows-removal-pr

Conversation

@marktoda
Copy link
Copy Markdown
Contributor

Summary

Both validate.yml and review-hook.yml query the GitHub PR files API without filtering by status. Removal-shaped PRs (e.g., reverting a hook entry) crash because:

  • validate.py receives a path that no longer exists on the PR head and fails with FileNotFoundError.
  • review-hook would ask Claude to verify a file against on-chain source even though the file is gone from the PR tree.

Surfaced while reverting #580 (the 0x0f7f… ShitGiftHook entry the submitter asked to drop after merge) — see PR #585, whose validate check is currently red purely from this bug.

Fix

  • Filter the API response with select(.status != "removed") in both workflows.
  • In validate.yml, reshuffle so the exact-diff policy (only hooks/**, exactly one file) still runs on the full changed-files list before the early-exit on "nothing to schema-validate." A naive filter-then-early-exit would let a PR remove a hook + modify a non-hook file and bypass policy.

Behavior matrix

PR shape Before After
Hook add/modify (1 hooks/ file) validate runs, review runs unchanged
Pure hook removal (1 hooks/ file) validate crashes policy enforced, nothing to validate, SUCCESS
Removal + non-hook file crashed before policy check policy fires, FAIL with error message
Non-hook PR (workflows, docs) both early-exit SUCCESS unchanged

Test plan

Both workflows pulled the changed-files list from the GitHub PR files API
without filtering by `status`, so any removal-shaped PR caused:

- `validate.py` to receive a path that no longer exists on the PR head,
  failing with FileNotFoundError before any schema check could run.
- `review-hook` to ask Claude to verify a file against on-chain source
  that no longer exists in the PR tree.

Filter the API response with `select(.status != "removed")`. In
`validate.yml`, also reshuffle so the "one file, all under hooks/" diff
policy still runs on the full changed-files list before the early-exit
on "nothing to schema-validate" — otherwise a PR could remove a hook
and modify a non-hook file in the same commit and bypass policy.

Hook addition/modification PRs behave identically to before. Pure
removal PRs now early-exit SUCCESS on both required checks instead of
crashing on FileNotFoundError.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hooklist Ready Ready Preview, Comment May 27, 2026 6:40pm

Request Review

@marktoda marktoda merged commit d4ca16b into main May 27, 2026
8 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.

1 participant