Laws are written in such a way that they don't allow the jury to decide if what the person did was right or wrong, just if they did or did not do what was said.
Do you agree they had a pipe in their possession? Yes - jail.
Do you agree they had the drug on them?
Yes -jail.
The jury doesn't get to decide if they think it was okay for them to have the pipe/drug on them. A lawyer does their best to spin it in a way that maybe makes it appear the officer illegally made a search to make all subsequent findings inadmissable and invalid for charging. Or that the possession was not actually the person. But usually it comes down to, we found this on your person... And conviction of possession.
Someone should argue that every arrest made by undercover officers pretending to be prostitutes should be thrown out under this.
Just because you said yes, or even paid, doesn't mean you would have actually had sex, so you in reality could have just paid to "test" if the prostitute would actually agree.