There are some holes in my plastic package of potatoes. Gnats got into them (maybe 20 or so) and were buzzing in and out of them until I shoed them away. Can I still either bake or boil the potatoes and eat them?
Opinion answer, no authority here, just going by what to me is common practice.
Potatoes are grown in the ground with dirt and bugs around all the time. In general, not a big deal. Gnats or small fruit flies are not an issue for a relatively hard and skinned item. As long as there is no soft spots or rot, just scrub then and you should be rid of any eggs they may have laid.
However, if the potatoes themselves were doing the attracting, that is a sign you may have rotting potaties. Those potatoes involved I would consider not only contaminated, but in danger of contaminating the remainder of the bag, drawing more unwanted visitors, and ready to smell up your world. I would remove any that show such signs.
If it is more than one or two, well, potatoes are relatively cheap in most places, so time for a new supply.