• 
      

    Serialize avatar URL in user resource only when URLs available

    Review Request #9457 — Created Dec. 19, 2017 and submitted

    Information

    Review Board
    release-3.0.x
    ed1a82f...

    Reviewers

    Previously we assumed that all avatar services would return URLs.
    However, it is possible that the service has yet to be configured for a
    user (e.g., they haven't uploaded an avatar yet for the
    FileUploadAvatarService) or the avatar service returns bad data. In
    these cases, we now wrap the serialization in a try..except to ensure
    that we don't cause exceptions that crash the resource.

    Additionally, we also ensure that we serialize the avatar_urls field
    as {} instead of None when there are no URLs to simplify
    deserialization logic.

    Ran unit tests.

    Description From Last Updated

    Can you update the description to also mention the change to the avatar_urls field? That'll make it easier to remember …

    chipx86chipx86

    This whole thing could be just return urls and urls.get('1x')

    daviddavid

    Single quotes.

    daviddavid

    Maybe worth having this return {} when there are no URLs? Simplifies the above code, simplifies clients who no longer …

    chipx86chipx86

    Plurals are wrong here. "avatar service"?

    chipx86chipx86
    david
    1. 
        
    2. reviewboard/webapi/resources/user.py (Diff revision 1)
       
       
       
       
       
       
       
       
      Show all issues

      This whole thing could be just return urls and urls.get('1x')

    3. reviewboard/webapi/tests/test_user.py (Diff revision 1)
       
       
      Show all issues

      Single quotes.

    4. 
        
    brennie
    david
    1. Ship It!

    2. 
        
    brennie
    chipx86
    1. 
        
    2. reviewboard/webapi/resources/user.py (Diff revision 3)
       
       
       
       
       
       
       
       
       
      Show all issues

      Maybe worth having this return {} when there are no URLs? Simplifies the above code, simplifies clients who no longer need to check for null but can instead just check for the presence of certain avatars (or check falsiness).

    3. reviewboard/webapi/tests/test_user.py (Diff revision 3)
       
       
      Show all issues

      Plurals are wrong here. "avatar service"?

    4. 
        
    brennie
    chipx86
    1. 
        
    2. Show all issues

      Can you update the description to also mention the change to the avatar_urls field? That'll make it easier to remember while writing release notes, and when coming across the modification down the road.

    3. 
        
    brennie
    david
    1. Ship It!
    2. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (f50e598)