This is a trope that I've seen sometimes in comic books. I haven't seen it in prose fiction yet.
Sometimes, we see a character who provides comic relief become highly capable for a single issue or chapter. Examples include a few Donald Duck stories, or Lambik from Suske & Wiske (Spike and Suzy).
This phenomenon usually happens when the story requires a strong character to get something done; the character who provides comic relief is a logical choice as they can afford to be somewhat inconsistent.
Is there a name for this trope?