From 03b043e1637227a8113c129e0a1109aaca811c69 Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:02:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Restores=20compatibility=20with?= =?UTF-8?q?=20deprecated=20storage=20API=20used=20in=20legacy=20services?= =?UTF-8?q?=20(#5679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/simcore_service_storage/handlers_files.py | 13 ++++++++----- .../tests/unit/test_handlers_files_metadata.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/services/storage/src/simcore_service_storage/handlers_files.py b/services/storage/src/simcore_service_storage/handlers_files.py index 3ec5699744c..3bb4dae2451 100644 --- a/services/storage/src/simcore_service_storage/handlers_files.py +++ b/services/storage/src/simcore_service_storage/handlers_files.py @@ -93,15 +93,18 @@ async def get_file_metadata(request: web.Request) -> web.Response: file_id=path_params.file_id, ) except FileMetaDataNotFoundError: - # NOTE: This is what happens Larry... data must be an empty {} or else some old - # dynamic services will FAIL (sic) - # TODO: once all legacy services are gone, remove the try except, it will default to 404 + # NOTE: LEGACY compatibility + # This is what happens Larry... data must be an empty {} or else some old dynamic services will FAIL (sic) + # Cannot remove until we retire all legacy services + # https://github.com/ITISFoundation/osparc-simcore/issues/5676 + # https://github.com/ITISFoundation/osparc-simcore/blob/cfdf4f86d844ebb362f4f39e9c6571d561b72897/services/storage/client-sdk/python/simcore_service_storage_sdk/models/file_meta_data_enveloped.py#L34 + return web.json_response( - {"error": "No result found", "data": None}, dumps=json_dumps + {"error": "No result found", "data": {}}, dumps=json_dumps ) if request.headers.get("User-Agent") == "OpenAPI-Generator/0.1.0/python": - # LEGACY compatiblity with API v0.1.0 + # NOTE: LEGACY compatiblity with API v0.1.0 # SEE models used in sdk in: # https://github.com/ITISFoundation/osparc-simcore/blob/cfdf4f86d844ebb362f4f39e9c6571d561b72897/services/storage/client-sdk/python/simcore_service_storage_sdk/models/file_meta_data_enveloped.py#L34 # https://github.com/ITISFoundation/osparc-simcore/blob/cfdf4f86d844ebb362f4f39e9c6571d561b72897/services/storage/client-sdk/python/simcore_service_storage_sdk/models/file_meta_data_type.py#L34 diff --git a/services/storage/tests/unit/test_handlers_files_metadata.py b/services/storage/tests/unit/test_handlers_files_metadata.py index 67e8a9f307a..87cbfcc1999 100644 --- a/services/storage/tests/unit/test_handlers_files_metadata.py +++ b/services/storage/tests/unit/test_handlers_files_metadata.py @@ -128,7 +128,7 @@ async def test_get_file_metadata( # NOTE: This needs to be a Ok response with empty data until ALL legacy services are gone, then it should be changed to 404! see test above assert response.status == status.HTTP_200_OK - assert await response.json() == {"data": None, "error": "No result found"} + assert await response.json() == {"data": {}, "error": "No result found"} # now add some stuff there NUM_FILES = 10