If there is one principle upon which I submit almost RPGs agree, it is that 'fuck you' moments are weak DMing. They belong in the realm of bad fantasy game books, in which you are regularly faced with binary choices in which one option leads to death without any fair warning whatsoever.
The devil, as always, is in the detail. What is a 'fuck you' moment? It is one in which a PC blamelessly dies or suffers serious harm. But that definition needs teasing out. We all know that if the PCs simply enter a room and the ceiling falls on their heads, and there was absolutely no way of them discovering this in advance or avoiding the result, then the DM is fucking them over. It's the edge cases, that are much more common, which need careful thought.
Here are some guidelines I think are appropriate:
1. It is not a 'fuck you' moment if the PCs fail to make adequate preparation in advance and suffer harm as a result. If they fail to bring adequate light sources in to the dungeon and get trapped in the dark, for instance, then that is just a natural consequence of their own actions.
2. It is not a 'fuck you' moment if the PCs simply get out of their depth in a dangerous environment as the result of a roll of the dice. The wilderness is dangerous. If they randomly encounter a red dragon in the mountains, and it kills them, it is not a 'fuck you' moment. (The analysis would be different if the DM simply inflicted a red dragon on them deliberately, on a whim.)
3. It is not a 'fuck you' moment if the PCs fail to perform proper reconnaissance. This could be as simple as having a scout tapping the ground with a 10' pole in a dungeon, or as complex as sending an invisible servant into an orc den to establish its contents. If the ceiling falls on the PCs but they could have discovered it was unstable by just stopping and looking or listening, or tapping it with a spear, then the results are fair.
4. It is not a 'fuck you' moment if a PC is poisoned or paralysed by a monster or dungeon 'scenery' or similar. These are expected risks.
5. It is not a 'fuck you' moment if a PC is made a target for revenge. If a PC makes enemies, then those enemies might attempt to assassinate, steal from, injure, or inconvenience him or her - and the results of this may be a complete surprise to the PC/player concerned. As long as the DM makes the appropriate rolls for those enemies fairly, then the results are also fair.
Can we add any others, or nuance the above?