Error code 500 trying to delete images from media library in Strapi dashboard

System Information
  • Strapi Version: 4.1.5
  • Operating System: OSX
  • Database: sqlite
  • Node Version: 14.17.1
  • NPM Version: 8.5.2
  • Yarn Version: 1.22.17

Error code 500 trying to delete images from media library in Strapi dashboard
Also ‘Replace Media’ sometimes throws 500 error and the image preview disappears from the dashboard but the image name/alt tag remains but now this is stuck in the dashboard Media Library and trying to delete it results in another 500 error.

Error: Error deleting on cloudinary: Cannot destructure property ‘resource_type’ of ‘file.provider_metadata’ as it is undefined.

Replace Media behaviour is odd as it allows to change (or not) the image name which means the file name and the image name can be different, that seems confusing? why wouldn’t replacing the image pull in the filename data as well?

Solved the issue of deleteing the rogue images by commenting out the Cloudinary config in config/plugins.js and restarting the server. It deleted everything from the media library which if in production would have been bad but thankfully only testing Strapi as a headless solution.

I still question the logic of being able to change the file name in the edit image dialogue though, especially if connected to third party cloud service.

My code is in production. I tried most fixes but want to be sure this is a guaranteed fix before i lose all my assets. Do I comment out the Cloudinary config, then restart the server, and add the Cloudinary config again?

That is not really SOLVING THE ISSUE:
Ok, after deactivating the cloudinary plugin the images in strapi “Media Library” can be deleted. But the same issue happens again when activating the cloudinary plugin.

This worked for me in development. But didn’t work in production.