If a star upgrade fails on a hero, you will lose a star. I know how you feel, it's happened to me countless times and then it cost me gems to buy medals tp upgrade them to the original start level.