Serialize avatar URL in user resource only when URLs available

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

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.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4
reviewboard/webapi/resources/user.py
reviewboard/webapi/tests/test_user.py
Loading...