The Fourth Amendment provides that law enforcement cannot conduct a search of property or person without a valid warrant. Any warrantless search is unlawful and should law enforcement arrest you pursuant to that search, the arrest itself becomes unlawful.
However, there are exceptions where a warrantless search is permitted under the law. One of those exceptions is consent to the search. As I have discussed elsewhere, you are not required under the law to consent to a search, and it is usually a good idea not to. Unfortunately, consent searches are quite frequent because people are often frightened and intimidated by the officer’s request. But even a consent search may be unlawful if consent is not voluntarily given.
If you consent to a search and you get arrested due to contraband found in the search, the arrest is presumed lawful because you consented to the search. But what if you consented because the police “strong-armed” you into allowing the search or threatened you or acquired your consent by deception? Whether the consent is voluntary or not is oftentimes difficult to determine, but it is the prosecutions burden to show in light of the circumstances that the consent was voluntarily given.