Skip to content

Commit 016cdec

Browse files
committed
fixed error handling
1 parent 78adcad commit 016cdec

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

services/storage/src/simcore_service_storage/api/rpc/_async_jobs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def result(
123123
exc_type = ""
124124
exc_msg = ""
125125
with log_catch(logger=_logger, reraise=False):
126-
task_error = TaskError.model_validate_json(_result)
126+
task_error = TaskError.model_validate(_result)
127127
exc_type = task_error.exc_type
128128
exc_msg = task_error.exc_msg
129129
raise JobError(job_id=job_id, exc_type=exc_type, exc_msg=exc_msg)

services/storage/tests/unit/test_rpc_handlers_simcore_s3.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from fastapi import FastAPI
2323
from fastapi.encoders import jsonable_encoder
2424
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobResult
25+
from models_library.api_schemas_rpc_async_jobs.exceptions import JobError
2526
from models_library.api_schemas_storage import STORAGE_RPC_NAMESPACE
2627
from models_library.api_schemas_storage.storage_schemas import (
2728
FileMetaDataGet,
@@ -98,7 +99,7 @@ async def _request_copy_folders(
9899
pytest.fail(reason="Copy folders failed!")
99100

100101

101-
@pytest.mark.xfail(reason="There is something fishy here MB, GC")
102+
# @pytest.mark.xfail(reason="There is something fishy here MB, GC")
102103
async def test_copy_folders_from_non_existing_project(
103104
initialized_app: FastAPI,
104105
storage_rabbitmq_rpc_client: RabbitMQRPCClient,
@@ -114,7 +115,9 @@ async def test_copy_folders_from_non_existing_project(
114115
incorrect_dst_project = deepcopy(dst_project)
115116
incorrect_dst_project["uuid"] = faker.uuid4()
116117

117-
with pytest.raises(RuntimeError, match="404") as exc_info:
118+
with pytest.raises(
119+
JobError, match=f"Project {incorrect_src_project['uuid']} was not found"
120+
):
118121
await _request_copy_folders(
119122
storage_rabbitmq_rpc_client,
120123
user_id,
@@ -123,14 +126,10 @@ async def test_copy_folders_from_non_existing_project(
123126
dst_project,
124127
nodes_map={},
125128
)
126-
# assert_status(
127-
# exc_info.value.response,
128-
# status.HTTP_404_NOT_FOUND,
129-
# None,
130-
# expected_msg=f"{incorrect_src_project['uuid']} was not found",
131-
# )
132-
133-
with pytest.raises(RuntimeError, match="404") as exc_info:
129+
130+
with pytest.raises(
131+
JobError, match=f"Project {incorrect_dst_project['uuid']} was not found"
132+
):
134133
await _request_copy_folders(
135134
storage_rabbitmq_rpc_client,
136135
user_id,
@@ -139,12 +138,6 @@ async def test_copy_folders_from_non_existing_project(
139138
incorrect_dst_project,
140139
nodes_map={},
141140
)
142-
# assert_status(
143-
# exc_info.value.response,
144-
# status.HTTP_404_NOT_FOUND,
145-
# None,
146-
# expected_msg=f"{incorrect_dst_project['uuid']} was not found",
147-
# )
148141

149142

150143
async def test_copy_folders_from_empty_project(

0 commit comments

Comments
 (0)