validate the uri better, and respond with errors in more cases