The PHB gives the following description of the 1st-level spell Command (emphasis mine), and I'm curious about the implications of the RAW here:
You speak a one-word command to a creature you can see within range. The target must succeed on a Wisdom saving throw or follow the command on its next turn. The spell has no effect if the target is undead, if it doesn’t understand your language, or if your command is directly harmful to it.
So my question is about the "directly harmful" clause. From an "in-universe" perspective, it seems reasonable that a creature's self-preservation instincts would prevent it from knowingly injuring itself; but what if the harm is caused by something that the Commanded creature is unaware of? For instance, if you poisoned one of their rations, could you command them to eat it?
Similarly, if neither the caster nor the Commanded creature are aware of the danger, would the command fail? For instance, if you order a creature to walk towards you, but there's a pit hidden by an illusion between the two of you.
If this causes the spell to fail, could it be used as a foolproof trap detector (Command a party member to walk down a hallway, knowing that the spell would prevent them from harming themselves, and thus prevent them from moving if there is a trap ahead)?