```target_uri``` is a URI object.  You probably wanted ```target_uri.path```