How can I check if a target's position is reachable by my AI?

I’ve been doing some digging and found reference to tagging nodes, checking path cost, and getTraversalCost, but those options are going over my head right now.

I have an AI that shoots out rocks. When the AI runs out of rocks, it finds the nearest rock, sets that rock as its target, and path finds to that rock to pick it up.
The issue I discovered is that the AI tries to go to the nearest rock even if the path is blocked.

is there an easy way I can run a simple check to see if the rock object’s position is reachable by my AI?

I’ve been writing my code in javascript, so I’m hoping there’s a solution that lets me call the check from a js script and get back a boolean.

Should I be looking in to any of the options I listed up top?

thank you so much for your time!