How do GraphUpdateObject and GraphUpdateShape work?

I have an npc and when it roams, it goes to the randomly genetated target. But this target must not be out of area. So I used GraphUpdateScene to create an area, took its bounds and created GraphUpdateObject and took its form to check if my target in the area.
But it does not work and give an issue “NullReferenceException: Object reference not set to an instance of an object”. I think I miss something. So how to make it work right?

The shape is optional. If it is null, the bounding box determines everything.