Stress testing and can't track error messages |
I wrote a little avatar upload method with Cropper.js, which works great, but I'm trying to stress test it, so I set the permissions on the original image that the upload is overwriting to 444. I can see it fail in the log perfectly, but what's going on with the rest of it I can't tell.
Cropper takes the cropped image portion and turns it into a PNG base64 string, so I had to (I think) write a custom validation to check that it's a good image. Here's everything I'm doing. Controller Method: PHP Code: public function upload() Custom Validation Rule: PHP Code: namespace App\Validation; Language File Validation: PHP Code: return [ Log Messages: Quote:CRITICAL - 2022-01-19 16:15:56 --> file_put_contents(/home/mysite/CI4path/writable/uploads/avatars/145208.png): failed to open stream: Permission denied
> I'm trying to stress test it, so I set the permissions on the original image that the upload is overwriting to 444.
I don't get what you say. What did you do exactly? The permission 444 means read only.
Hi @kenjis,
I'm trying to make it fail in testing, so that I can add logic to account for possible real-world issues. By setting the read only permission, I'm testing if the file could not be saved to disk. This testing is not the issue I'm asking about though, it's the rest of the log file detail that I can't account for. Code: Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse json string, error: "Malformed UTF-8 characters, possibly incorrectly encoded". in /home/mysite/CI4path/vendor/codeigniter4/framework/system/Format/JSONFormatter.php:41
As you see, it comes from Debug/Exceptions.php -> API/ResponseTrait.php -> Format/JSONFormatter.php.
It is because of the first error. #0 /home/mysite/CI4path/vendor/codeigniter4/framework/system/Format/JSONFormatter.php(41): CodeIgniter\Format\Exceptions\FormatException::forInvalidJSON('Malformed UTF-8...') #1 /home/mysite/CI4path/vendor/codeigniter4/framework/system/API/ResponseTrait.php(341): CodeIgniter\Format\JSONFormatter->format(Array) #2 /home/mysite/CI4path/vendor/codeigniter4/framework/system/API/ResponseTrait.php(99): CodeIgniter\Debug\Exceptions->format(Array) #3 /home/mysite/CI4path/vendor/codeigniter4/framework/system/Debug/Exceptions.php(115): CodeIgniter\Debug\Exceptions->respond(Array, 500) #4 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) |
Welcome Guest, Not a member yet? Register Sign In |