I agree. You say the player will likely spend 30-40 turns after committing a game-killing blunder doing something else, and then return to find that the seemingly obvious course of action (is it possible for the character to find the candy but not the rotten food?) has doomed them. In fact, if I were in that situation - having fed the guard the candy only to discover he catches me if I return, and having never seen the rotten food nor determined its purpose - my immediate assumption would be that my fatal blunder was something I did during the escape itself, and not my choice of bribe. So unless there’s something in this setup you haven’t explained adequately, it’s likely that the player will not only be stuck, but left clutching at straws as to why.
May I make a recommendation? Put a laxative or some such into the player’s hands (seriously, find some excuse to force them to bring it along - maybe stash it in a first aid kit or other container that the player will need to obtain) and clue its potential use before the player finds the candy. This way, the player can doctor the candy before he gives it to the guard - or not. Then the onus of failure falls on the player for not disposing of the guard with the supplied tools, instead of the designer for making it possible to stumble upon an irrevocable false solution before finding the correct one.
Alternately, put the laxative wherever you like, and make it so that the guard simply accepts the candy as a gift - only the doctored candy will make him leave his post. (Depending on whether you can get more candy after this, this either presents a more “fair” unwinnable condition which can be immediately UNDO’d, or simply another obstacle the player must overcome to proceed.)