There's no "right" answer, there are major playstyles that hit the two extremes and then there's compromises in the middle. The ENWorld post Combat as Sport vs Combat As War illustrates two different end state playstyles - in "combat as sport" the GM never makes "level inappropriate" encounters (no matter how hard you have to twist logic to get there), with each combat being specifically a "fair" setpiece, and in "combat as war" whatever happens happens, whether that means the PCs win without even fighting by poisoning the enemies' water supply or whether it's a TPK because they're dunderheads.
Now, these are two extremes which usually people don't do a pure version of. 4e tended toward Combat as Sport and earlier versions tended toward Combat as War. Given D&D 5e's inheritance of all those playstyles, I think you should think about where you want to fall on that spectrum and then be consistent, and communicate to your players what your approach is so they have aligned expectations.
Most people I have gamed with would let the chips fall where they may, but would make sure and telegraph that it's coming. See How can DMs effectively telegraph specific dangers in D&D?How can DMs effectively telegraph specific dangers in D&D? for a question entirely about that. In this case I personally would have them come across various other "hastily abandoned" rooms, maybe run across a messenger or group sending or responding to the "everyone gather up in the main hall to kill intruders!" summons, etc. I often find that doubling down on in-game reality helps - all the bad guys don't just immediately know the wizard wants them and teleport to his side, right, there's a fair amount of alarm generation, people running to and fro, etc. to make it happen. Heck, there's probably one or two folks who are aware of but don't respond to the summons (are sick, or cowardly, or just don't like the wizard that much) that the PCs could find and interrogate. The wizard may have powerful allies he doesn't exactly trust to fight in the same room as him (evil folks are always out to advance themselves with a dagger in the back of their boss) so maybe he deliberately sends some out on a reconnaissance in force. All these can be ways for the PCs to learn that an ambush of overwhelming force might await them. The solution to that, however, is their problem. Smart tactics? Wait them out? Cloudkill scroll? Heavy buffing including fire resistance? There's a lot of options for smart players.
But if they ignore all that and eschew intel gathering to go with a "LEEEEEEEROY JENKINS!!!!" approach then it's OK to kill all the PCs to make their players smarter. As others have noted, you could also opt to capture them or "leave one alive to spread the word of your infamy" but in my experience players hate these as much as just getting wiped out, so I'm not sure if there's value there - depends on how epic of a campaign you're running and how much work you're losing with a new set of PCs. They're only level 2, so it's on the low investment side, once they've been playing a while they'll have had a lot of characters die. The first time needs more hugs but it's going to happen, may as well happen now.
Keep in mind that ambush doesn't have to be the NPC's reaction, it could be escape or something else, depending on their motivations. So don't feel forced into that as a decision, but if you want to make that decision it's a legitimate one.