The law used to allow a defendant to present the affirmative defense, if the entry or attempted entry was unlawful. If the entry was lawful, the affirmative defense never did exist.
If the entry was lawful, but the defendant reasonably believed it to be unlawful on its face, I would expect that such a thing could have been usable as an affirmative defense, although it would rarely be applicable. The fact that a reasonable person would regard a search as facially unlawful would normally tend to imply that the search was conducted in unreasonable fashion, and was consequently unlawful. The only situation where such an affirmative defense would be meaningful would be if some condition, of which the cops were not aware, prevented the defendant from recognizing the legitimacy of the search. For example, suppose the defendant (target of the warrant) was a foreign national from some particular country, and the cops--being aware of this--got a warrant printed out in the common language of that country but unfortunately not in a language the defendant happened to read. The defendant should not be prosecuted for refusing entry to the cops who failed to give him a warrant he could actually read, but the fact that the cops didn't know what language the defendant could read should not imply that the search wasn't lawful.
Otherwise, do you agree with the importance of distinguishing between facially unlawful acts and acts which were facially valid despite being illegitimate? If cop #1 uses perjured testimony to get a warrant, and cop #2, without knowing of the perjury, uses the warrant to conduct a search, the search should be regarded as illegitimate but that doesn't make cop #2 a robber. On the other hand, if a cop tries to enter 742 Evergreen Terrace with a warrant which is written out for 547 Morning Glory Circle, and persists in trying to enter even after the discrepancy is pointed out, such a cop fails to be performing his official duties and should be regarded as the robber he is.