You don't lose a star even if you fail for certain levels.

Read the tooltip (question mark in a circle in the Star tab) before starring.