As discussed in person, this seems like a sign that your API isn't behaving in the best way. If the API always returns a dict for the "uid" key, this type checking isn't needed.