Skip to content

Commit

Permalink
fix: be defensive about pulling both email and external_id from braze…
Browse files Browse the repository at this point in the history
… export.
  • Loading branch information
iloveagent57 committed Jan 29, 2024
1 parent 5a1f485 commit 08698ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Change Log
Unreleased
~~~~~~~~~~

[0.2.2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix: be defensive about pulling both ``email`` and ``external_id`` from braze export.

[0.2.1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix: be defensive about pulling external_id from braze export.
Expand Down
2 changes: 1 addition & 1 deletion braze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Python client for interacting with Braze APIs.
"""

__version__ = '0.2.1'
__version__ = '0.2.2'
5 changes: 4 additions & 1 deletion braze/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def get_braze_external_id_batch(self, emails, alias_label):
response = self._make_request(payload, BrazeAPIEndpoints.EXPORT_IDS, REQUEST_TYPE_POST)

for identified_user in response['users']:
external_ids_by_email[identified_user['email']] = identified_user.get('external_id')
identified_email = identified_user.get('email')
external_id = identified_user.get('external_id')
if identified_email and external_id:
external_ids_by_email[identified_email] = external_id

logger.info(f'external ids from batch identify braze users response: {external_ids_by_email}')
return external_ids_by_email
Expand Down
9 changes: 8 additions & 1 deletion tests/braze/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ def test_create_braze_alias_user_exists(self):
responses.add(
responses.POST,
self.EXPORT_ID_URL,
json={'users': [{'external_id': existing_enternal_id, 'email': test_email}], 'message': 'success'},
json={
'users': [
{'external_id': existing_enternal_id, 'email': test_email},
{'external_id': '123'},
{},
],
'message': 'success'
},
status=201
)
responses.add(
Expand Down

0 comments on commit 08698ab

Please sign in to comment.