test(ignore-service): skip EACCES test under uid=0 (root bypasses chmod)#1108
Merged
magyargergo merged 1 commit intoApr 27, 2026
Merged
Conversation
The `loadIgnoreRules — error handling > warns on EACCES but does not
throw` test relies on `chmod 000` denying read access to a temporary
.gitignore file. On Linux, root bypasses POSIX read-permission checks,
so chmod 000 does NOT trigger EACCES under uid=0 — fs.readFile reads
the file anyway and loadIgnoreRules returns parsed rules instead of
the `null` the test expects.
Symptom under root: assertion fails with `Ignore { _rules: [...] }
to be null`, surfaced as a single test failure in any privileged
test environment (rootful Docker container, CI runners configured to
run tests as root, etc.).
Fix: extend the existing `skipIf(process.platform === 'win32')` guard
with `process.getuid?.() === 0`. The non-root code path still
exercises the real EACCES branch — root just can't reproduce the
failure mode the test asserts on, so skipping there is the correct
posture (matches the win32 skip's reasoning: the OS-level mechanism
the test depends on isn't available there).
Optional chaining (`getuid?.()`) keeps Windows compatibility — Node
on Windows doesn't expose `process.getuid` at all.
|
@mann1x is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
Merged
5 tasks
Contributor
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 7475 tests passed 97 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
Collaborator
|
Thank you for this PR! |
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
The
loadIgnoreRules — error handling > warns on EACCES but does not throwtest intest/unit/ignore-service.test.ts(line 564 pre-fix) writes a temporary.gitignore, runschmod 000on it, and asserts thatloadIgnoreRulesreturnsnullbecause the read fails withEACCES. This works on a typical developer laptop, but fails when the test runs underuid=0: root bypasses POSIX read-permission checks on Linux, sochmod 000does NOT triggerEACCES—fs.readFilereads the file anyway andloadIgnoreRulesreturns the parsed rules object instead ofnull.Repro under
node:22-trixie-slimrunning as root:This breaks any privileged test environment — rootful Docker, certain CI runners, etc. — without saying anything useful about the code under test.
Fix
Extend the existing
skipIf(process.platform === 'win32')guard withprocess.getuid?.() === 0so the test is skipped under root. The non-root code path is unchanged and still exercises the real EACCES branch. Root simply cannot reproduce the failure mode the test asserts on, so skipping is the correct posture there — matches the win32 skip's reasoning (the OS-level mechanism the test depends on isn't available).Optional chaining (
getuid?.()) keeps Windows compatibility — Node on Windows doesn't exposeprocess.getuidat all, so the call must short-circuit cleanly.Test plan
npx vitest run test/unit/ignore-service.test.tsunderuid=0(rootful container): 132 passed / 1 skipped, was 132 passed / 1 failed pre-fix.it.skipIf(false)still runs the body, which already passes in upstream CI.npx tsc --noEmitclean.Spotted while validating PR #1087 (the
canParentScoperefactor) where the dockerized test environment runs as root. Sending as a separate PR because it has nothing to do with scope-resolution.🤖 Generated with Claude Code