🐛 **Handle MissingFileUploadsTrait exceptions gracefully**

-  Added detection logic for `MissingFileUploadsTraitException` to prevent 500 errors.
- 🛠️ Updated exception handling to return a 400 response for these scenarios.
- 🔇 Suppressed logging of `MissingFileUploadsTraitException` to reduce noise.
-  Added tests to verify 400 responses and absence of log entries.
This commit is contained in:
HolgerHatGarKeineNode
2026-05-20 10:54:12 +02:00
parent 03aacdb8ff
commit e3f8c4c232
2 changed files with 64 additions and 2 deletions
@@ -0,0 +1,49 @@
<?php
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
use Livewire\Features\SupportFileUploads\MissingFileUploadsTraitException;
function throwMissingFileUploadsTraitException(): never
{
$component = new class extends Component
{
public function getName(): string
{
return 'language.selector';
}
public function render(): string
{
return '<div></div>';
}
};
throw new MissingFileUploadsTraitException($component);
}
it('returns 400 for MissingFileUploadsTraitException instead of 500', function () {
Route::get('/_test/missing-file-uploads-trait', function () {
throwMissingFileUploadsTraitException();
});
$response = $this->get('/_test/missing-file-uploads-trait');
expect($response->status())->toBe(400);
});
it('does not report MissingFileUploadsTraitException to the logs', function () {
Log::spy();
Route::get('/_test/missing-file-uploads-trait-log', function () {
throwMissingFileUploadsTraitException();
});
$this->get('/_test/missing-file-uploads-trait-log')
->assertStatus(400);
Log::shouldNotHaveReceived('error');
Log::shouldNotHaveReceived('critical');
Log::shouldNotHaveReceived('emergency');
});