Whenever our application tries to pull messages from MESH and there are more than 500 messages the MESH client throws the following exception:
ERROR MissingSchema: Invalid URL '/messageexchange/**********/inbox...
No scheme supplied. Perhaps you meant https:///messageexchange/**********/inbox...
File \"/var/task/mesh_client/__init__.py\", line 816, in iterate_message_ids",
result = self._inbox_v2_page(url=next_page)",
File \"/var/task/mesh_client/__init__.py\", line 507, in _inbox_v2_page",
response = self._session.get(url, timeout=self._timeout, params=params)",
File \"/var/task/requests/sessions.py\", line 602, in get",
return self.request(\"GET\", url, **kwargs)",
File \"/var/task/requests/sessions.py\", line 575, in request",
prep = self.prepare_request(req)",
File \"/var/task/requests/sessions.py\", line 486, in prepare_request",
p.prepare(",
File \"/var/task/requests/models.py\", line 368, in prepare",
self.prepare_url(url, params)",
File \"/var/task/requests/models.py\", line 439, in prepare_url",
raise MissingSchema(",
"links": {
"self": "/messageexchange/X26ABC1/inbox"
},
Context
We are using version 3.2.1 of the MESH-client.
We are testing the last step of the pseudocode for MESH inbox cycle explained here: https://digital.nhs.uk/developer/api-catalogue/message-exchange-for-social-care-and-health-api#overview--mesh-api-pseudocode
Whenever our application tries to pull messages from MESH and there are more than 500 messages the MESH client throws the following exception:
With the following stack trace:
This occurs when trying to load the second batch of message (500 till the end). The reason is that the client expects the links object in the response to contain a fully qualifying URI: https://github.com/NHSDigital/mesh-client/blob/develop/mesh_client/__init__.py#L807-L817
Where instead the returned links object looks like this:
Potential Fix
This can be fixed by either
Updating the way that _inbox_v2_page function builds the url: https://github.com/NHSDigital/mesh-client/blob/develop/mesh_client/__init__.py#L506 To check the argument passed is a fully qualified url.
or the same check can be performed when extracting the URL from the links object here:
https://github.com/NHSDigital/mesh-client/blob/develop/mesh_client/__init__.py#L807