Faulty Negative Cost sensor entry

I’m running into a weird issue where on restart of my HA instance I’m getting a massive one time negative cost value entered into my energy cost sensor.

So far I’m able to go into the outliers and remove the faulty entries and everything goes back to expected values. I’d love to know if there’s a way to prevent this from happening.