Serialize avatar URL in user resource only when URLs available
Review Request #9457 — Created Dec. 19, 2017 and submitted
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 atry..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 ofNone
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 … |
chipx86 | |
This whole thing could be just return urls and urls.get('1x') |
david | |
Single quotes. |
david | |
Maybe worth having this return {} when there are no URLs? Simplifies the above code, simplifies clients who no longer … |
chipx86 | |
Plurals are wrong here. "avatar service"? |
chipx86 |
- Change Summary:
-
Addressed David's issues.
- Commit:
-
dcb9006e835285b8cef9925ecd3bbbb6b5e2e7e1357e9fb2bf34aa34508375603bd833d1c3b717a0
Checks run (2 succeeded)
- Change Summary:
-
Dont return {} from no urls
- Commit:
-
357e9fb2bf34aa34508375603bd833d1c3b717a0ea89767a873a2ad4e17c6abd3c9f930f73004fc3
Checks run (2 succeeded)
- Change Summary:
-
Addressed Christian's issues.
- Commit:
-
ea89767a873a2ad4e17c6abd3c9f930f73004fc3ed1a82f689642e00f5d10fe569e6db27f5a13347
Checks run (2 succeeded)
- Change Summary:
-
Addressed Christian's issue.
- Description:
-
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. Inthese cases, we now wrap the serialization in a try..except
to ensurethat we don't cause exceptions that crash the resource. + + Additionally, we also ensure that we serialize the
avatar_urls
field+ as {}
instead ofNone
when there are no URLs to simplify+ deserialization logic.