Skip to content

fix(ci): don't validate company files a PR removed - #2255

Merged
dougaitken merged 1 commit into
remoteintech:mainfrom
dougaitken:fix/validate-rename-enoent
Sep 7, 2026
Merged

fix(ci): don't validate company files a PR removed#2255
dougaitken merged 1 commit into
remoteintech:mainfrom
dougaitken:fix/validate-rename-enoent

Conversation

@dougaitken

Copy link
Copy Markdown
Member

Surfaced while reviewing #2247, but fixed independently since it affects every contributor PR of this shape.

The bug

validate-companies.yml built its file list from gh pr diff --name-only. On a rename that returns both paths:

src/companies/redlio-designs.md   <- deleted by the PR
src/companies/redlio-labs.md

The mapping loop then prefixes each with pr-head/, but the deleted file isn't in the sparse head checkout, so validate-companies.js failed:

Could not read file: ENOENT: no such file or directory,
open 'pr-head/src/companies/redlio-designs.md'

That's an unconditional exit 1, so the workflow blocked the PR over a file it had legitimately deleted — while the file it actually added validated clean. Any PR removing a profile hit the same wall.

The fix

List changed files through the pulls API and drop removed entries, so only paths present in the checkout are validated. This is preferable to just testing -f on each path, which would mask a genuinely missing file.

Verified against the live PRs:

PR Shape Before After
#2247 rename both paths → ENOENT redlio-labs.md only
#2249 edit soshace.md soshace.md (unchanged)
#2250 add first-point.md first-point.md (unchanged)

The mapping loop keeps a -f check as defence-in-depth, but now emits ::warning:: instead of skipping silently, and the step short-circuits cleanly if nothing is left to validate (the comment step already returns early on an empty result, so no comment is posted).

Verification

YAML parses, mapping-loop logic exercised locally across rename / all-missing / multi-file cases, and npm run build is clean (981 files).

Credit to @mayursinh1211, who diagnosed this correctly on #2247.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MMca9WXKJAriMEfghGw1eT

The Validate Company Profiles workflow built its file list from
`gh pr diff --name-only`, which reports both the old and new path
when a PR renames a company profile. The old path is absent from the
sparse pr-head checkout, so validate-companies.js failed with ENOENT
and blocked the PR over a file it had legitimately deleted. Any PR
removing a profile hit the same wall.

List changed files through the pulls API instead and drop entries with
status "removed", so only files present in the checkout are validated.
Verified against remoteintech#2247 (rename -> yields only the added file) and
remoteintech#2249 (edit -> unchanged behaviour).

Also guards the mapping loop with a warning rather than a silent skip,
and short-circuits cleanly when nothing is left to validate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMca9WXKJAriMEfghGw1eT
@dougaitken
dougaitken merged commit 7d58a45 into remoteintech:main Sep 7, 2026
7 checks passed
@dougaitken
dougaitken deleted the fix/validate-rename-enoent branch September 7, 2026 20:51
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