so digging into this a bit more it seems to only come up for users using gravatar. The $params array is pulling the right URL but for gravatar links it throws the bad uri error.
Here is what the url looks like in my array.
[avatar_url] => http://2.gravatar.com/avatar/8873fecd2e0ccc4af0c54c8bdb1aab99?s=96&d=mm&r=x
Entering this url into my browser returns the correct avatar image.
Edit: It seems Discourse does not like the parameters that are at the end of the Gravatar URL if i strip off everything after the hash for the gravatar is goes through fine.