From 4602c019799409f6f3153eacb84b946d6e8dfd02 Mon Sep 17 00:00:00 2001 From: William Date: Wed, 18 Nov 2026 11:03:24 +0000 Subject: [PATCH 1/2] fix: include Leaf\FS\File errors in Request::errors() --- src/Request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Request.php b/src/Request.php index 31dcb85..1e8aed2 100755 --- a/src/Request.php +++ b/src/Request.php @@ -878,7 +878,8 @@ public static function errors() return array_merge( static::$errors, static::$validator ? static::$validator->errors() : [], - class_exists('\Leaf\Auth') ? static::auth()->errors() : [] + class_exists('\Leaf\Auth') ? static::auth()->errors() : [], + \Leaf\FS\File::errors() ); } } From 1bc27b550188de3930b0cf70771c32752ced2d2c Mon Sep 17 00:00:00 2001 From: William Date: Wed, 18 Nov 2026 15:07:04 +0000 Subject: [PATCH 2/2] test: cover upload errors surfacing through Request::errors() --- tests/request.test.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/request.test.php b/tests/request.test.php index 0929dd1..634399f 100644 --- a/tests/request.test.php +++ b/tests/request.test.php @@ -121,3 +121,32 @@ expect(Request::files(['avatar', 'missing']))->toBe(['avatar' => ['name' => 'me.png'], 'missing' => null]); expect(Request::files())->toHaveKeys(['avatar', 'doc']); }); + +test('errors includes failures recorded by the file system on upload', function () { + fakeRequest(); + + $errors = new ReflectionProperty(\Leaf\FS\File::class, 'errorsArray'); + $errors->setValue(null, []); + + $_FILES = ['avatar' => [ + 'name' => 'big.png', + 'type' => 'image/png', + 'tmp_name' => '/tmp/does-not-matter', + 'error' => 0, + 'size' => 5000, + ]]; + + expect(Request::upload('avatar', sys_get_temp_dir(), ['maxSize' => 100]))->toBeFalse(); + expect(Request::errors())->toHaveKey('upload'); + + $errors->setValue(null, []); +}); + +test('errors includes the extension failure raised by Request::upload itself', function () { + fakeRequest(); + + $_FILES = ['doc' => ['name' => 'run.exe', 'type' => 'application/x-msdownload', 'tmp_name' => '/tmp/x', 'error' => 0, 'size' => 10]]; + + expect(Request::upload('doc', sys_get_temp_dir(), ['extensions' => ['pdf']]))->toBeFalse(); + expect(Request::errors())->toHaveKey('upload'); +});