Had the exact same problem, although it might have been the left rear. Tail lights worked, but when you depressed the brake pedal with the lights on, the bulb (brake light) would go out! Very weird, as the brake lights worked fine when the lights were off during the day??
Anyhow, dealer replaced the bulb and cleaned contacts as you did, and it's been fine since. Mine (the bulb) also had never been out/replaced from the factory, and the tech told me the contacts were quite dry and corroded. Now that I think of it, he actually wired in a new bulb socket in addition to the bulb. All under warranty.