fix: skip unreadable .env in Boot::loadDotEnv for separate-process tests - #10417
fix: skip unreadable .env in Boot::loadDotEnv for separate-process tests#10417gr8man wants to merge 1 commit into
Conversation
michalsn
left a comment
There was a problem hiding this comment.
Now we would silently ignore a present but unreadable .env file. Not acceptable.
If you identified the test that causes this, you may configure the test bootstrap to use a controlled environment directory.
352e956 to
92eac67
Compare
michalsn
left a comment
There was a problem hiding this comment.
Please identify the test or operation that changes the file's permissions and causes the error.
I cannot recreate the issue by running the test command you provided.
PHPUnit 11.5.56 by Sebastian Bergmann and contributors. Runtime: PHP 8.5.8 Time: 00:09.249, Memory: 26.00 MB There was 1 error:
https://github.com/codeigniter4/CodeIgniter4/actions/runs/29701403791/job/88230952540#step:10:249 |
|
I found the likely root cause of the test failure — it was in
Fixed in commit 4875736: instead of moving the whole file, the test now only clears the With this fix, no framework changes are needed ( |
92890fc to
9fdc43e
Compare
michalsn
left a comment
There was a problem hiding this comment.
This cannot be the root cause of the reported random-test failure. The Encryption component was not enabled in the random-test configuration used by that run, so EncryptionTest was never executed.
The change may be a reasonable test cleanup, but it does not explain or resolve the cited failure.
40f9a4b to
01e60c2
Compare
c1ee0ec to
9a4c7ad
Compare
The .env file may be removed or replaced by a concurrent process between the is_file() check and the read attempt, e.g. another test process renaming ROOTPATH/.env. The previous is_readable() pre-check performed a fresh access() syscall that could fail on a just-renamed file, crashing CI with 'The .env file is not readable'. Read the file first and only throw when it still exists after a re-check with a fresh stat cache.
9a4c7ad to
148c23a
Compare
Description
Test
ResponseSendTest::testHeaderOverridefails when tests run in random order because the spawned process (#[RunInSeparateProcess]) callsBoot::loadDotEnv()→DotEnv::parse(), which throwsInvalidArgumentExceptionwhen.envexists but is unreadable. The fix adds an earlyis_file()+is_readable()guard soloadDotEnv()returns silently —.envis optional.Tests
No new tests —
DotEnvTest::testLoadsUnreadableFilealready covers the exception path. Verified with: