An important aspect to keep in mind is if this sort of thing is within the sphere of what the players expect to reasonably deal with. (In other words, the social contract)
If the players are expecting 'jolly adventurers roaming the countryside and slaying orcs', having a trap spring in the middle of the dungeon with the effect of 'your character is now mind-controlled, you should've prepared against mental invasion' is probably outside their expectations, and the players could be angry with you, even if you pointed to the module or rulebook and said 'It's totally valid'.
Alternately, if the players aren't thinking of intrigue and trustworthiness as an issue, if the spy succeeds (presumably harming the party or the party's goals), saying "You could've figured out that one of your party members had hidden motives" isn't likely to be seen as a fine explanation. This is doubly true because unless you and the player-spy actively drop hints as to their nature, because RPGs are created in terms of narration. If the players don't know to look for suspicious things, they won't.
To turn it back into a more concrete example:
GM:"You walk into the corridor. Once the door closes, spears fly out from the walls and floor. You are all impaled."
Players: "What spears?"
GM: "They came from the holes in the walls."
Players: "You didn't describe any holes."
GM: "You didn't ask."
In other words, nobody wins. On the other hand though, they could find the sudden change great. It's really dependent upon the party.