AI can't detect if path is valid

I am trying to build an AI to detect a target and then determine if there is a valid path to it.
For instance I have a house surrounded by a fence, the house is the target. There should not be a valid path, but it always returns path is valid.

I want to know if there is a gap in the back, then the AI can go to that path, if there is no valid path, then are any of routes to that target blocked by an object it can destroy.

Does anyone have a solution for this?