Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions firebase_admin/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,12 @@ def _handle_iid_error(self, error):
except ValueError:
pass

# IID error response format: {"error": "some error message"}
msg = data.get('error')
if not msg:
# IID error response format: {"error": "ErrorCode"}
code = data.get('error')
msg = None
if code:
msg = 'Error while calling the IID service: {0}'.format(code)
else:
msg = 'Unexpected HTTP response with status: {0}; body: {1}'.format(
error.response.status_code, error.response.content.decode())

Expand Down
4 changes: 2 additions & 2 deletions tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ def test_subscribe_to_topic_error(self, status, exc_type):
status=status, payload=self._DEFAULT_ERROR_RESPONSE)
with pytest.raises(exc_type) as excinfo:
messaging.subscribe_to_topic('foo', 'test-topic')
assert str(excinfo.value) == 'error_reason'
assert str(excinfo.value) == 'Error while calling the IID service: error_reason'
assert len(recorder) == 1
assert recorder[0].method == 'POST'
assert recorder[0].url == self._get_url('iid/v1:batchAdd')
Expand Down Expand Up @@ -2318,7 +2318,7 @@ def test_unsubscribe_from_topic_error(self, status, exc_type):
status=status, payload=self._DEFAULT_ERROR_RESPONSE)
with pytest.raises(exc_type) as excinfo:
messaging.unsubscribe_from_topic('foo', 'test-topic')
assert str(excinfo.value) == 'error_reason'
assert str(excinfo.value) == 'Error while calling the IID service: error_reason'
assert len(recorder) == 1
assert recorder[0].method == 'POST'
assert recorder[0].url == self._get_url('iid/v1:batchRemove')
Expand Down