Fix catching invalid type when deleting a folder