Skip to content

Commit 8b5485a

Browse files
committed
change/logging: edu-sharing API client init fallback when "services" list is empty
- early edu-sharing v9.x versions didn't provide a list of services in the initial about["services"] API response, which was a confirmed bug and has been fixed - since the fallback is no longer necessary in "healthy" edu-sharing versions, a logging message will be shown (to make devs aware when the fallback is active)
1 parent d0238b2 commit 8b5485a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

converter/es_connector.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,16 @@ def init_api_client(self):
815815
EduSharing.nodeApi = NODEV1Api(EduSharing.apiClient)
816816
about = EduSharing.aboutApi.about()
817817
if "services" in about and about["services"]:
818-
# edu-sharing API v6.x to v8.1 behavior: looking for the BULK v1 API "version"-dict
818+
# edu-sharing API v6.x to v9.1 behavior: look for the BULK v1 API "version"-dict
819819
EduSharing.version = \
820820
list(filter(lambda x: x["name"] == "BULK", about["services"]))[0]["instances"][0]["version"]
821-
elif "version" in about and about["version"]:
822-
# edu-sharing API v9.x behavior:
823-
# we expect a "version"-dict to exist within the "about"-dict that might look like this:
821+
elif "services" in about and not about["services"] and "version" in about and about["version"]:
822+
# edu-sharing API v9.x workaround:
823+
# if about["services"] is an empty list (instead of the expected list[dict]),
824+
# we're falling back to the about["version"]-dict that might look like this:
824825
# {'major': 1, 'minor': 1, 'renderservice': '9.0', 'repository': '9.0'}
826+
log.info(f"Failed to retrieve BULK v1 API version from edu-sharing during APi client init: "
827+
f"about['services'] was empty (expected: list[dict]). Using about['version'] fallback...")
825828
EduSharing.version = about["version"]
826829
version_str: str = f"{EduSharing.version['major']}.{EduSharing.version['minor']}"
827830
if (

0 commit comments

Comments
 (0)