File tree 1 file changed +13
-3
lines changed
src/sentry/api/serializers/models/organization_member
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -100,13 +100,23 @@ def serialize(
100
100
) -> OrganizationMemberResponse :
101
101
serialized_user = attrs ["user" ]
102
102
if obj .user_id :
103
- # Only use the user's primary email from the serialized user data
103
+ # if the OrganizationMember has a user_id, the user has an account
104
+ # `email` on the OrganizationMember will be null, so we need to pull
105
+ # the email address from the user's actual account
104
106
email = serialized_user ["email" ] if serialized_user else obj .email
105
107
else :
106
- # For invited members, use the invitation email
108
+ # when there is no user_id, the OrganizationMember is an invited user
109
+ # and the email field on OrganizationMember will be populated, so we
110
+ # will use it directly
107
111
email = obj .email
108
112
109
- # helping mypy - we know email will never be None based on the model
113
+ # helping mypy - the email will always be populated at this point
114
+ # in the case that it is a user that has an account, we pull the email
115
+ # address above from the serialized_user. The email field on OrganizationMember
116
+ # is null in the case, so it is necessary.
117
+ #
118
+ # invited users do not yet have a full account and the email field
119
+ # on OrganizationMember will be populated in such cases
110
120
assert email is not None
111
121
112
122
inviter_name = None
You can’t perform that action at this time.
0 commit comments