Skip to content

Commit 045aa49

Browse files
committed
add 404 in case result is not done
1 parent 2bb2a5e commit 045aa49

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

api/specs/web-server/_storage.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ async def abort_async_job(job_id: AsyncJobId):
226226
"/storage/async-jobs/{job_id}/result",
227227
response_model=Envelope[StorageAsyncJobResult],
228228
name="get_async_job_result",
229+
responses={
230+
status.HTTP_404_NOT_FOUND: {
231+
"description": "Result not found",
232+
"model": StorageAsyncJobStatus,
233+
}
234+
},
229235
)
230236
async def get_async_job_result(job_id: AsyncJobId):
231237
"""Get the result of the async job"""

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6477,12 +6477,18 @@ paths:
64776477
application/json:
64786478
schema:
64796479
$ref: '#/components/schemas/Envelope_StorageAsyncJobResult_'
6480+
'404':
6481+
description: Result not found
6482+
content:
6483+
application/json:
6484+
schema:
6485+
$ref: '#/components/schemas/StorageAsyncJobStatus'
64806486
/v0/storage/async-jobs:
64816487
get:
64826488
tags:
64836489
- storage
64846490
summary: Get Async Jobs
6485-
description: Retrunsa list of async jobs for the user
6491+
description: Returns a list of async jobs for the user
64866492
operationId: get_async_jobs
64876493
parameters:
64886494
- name: user_id

services/web/server/src/simcore_service_webserver/storage/_rest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,21 @@ async def get_async_job_result(request: web.Request) -> web.Response:
544544

545545
rabbitmq_rpc_client = get_rabbitmq_rpc_client(request.app)
546546
async_job_get = parse_request_path_parameters_as(_StorageAsyncJobId, request)
547+
548+
async_job_rpc_status = await get_status(
549+
rabbitmq_rpc_client=rabbitmq_rpc_client,
550+
rpc_namespace=STORAGE_RPC_NAMESPACE,
551+
job_id=async_job_get.job_id,
552+
job_id_data=AsyncJobNameData(
553+
user_id=_req_ctx.user_id, product_name=_req_ctx.product_name
554+
),
555+
)
556+
if not async_job_rpc_status.done:
557+
return create_data_response(
558+
async_job_rpc_status,
559+
status=status.HTTP_404_NOT_FOUND,
560+
)
561+
547562
async_job_rpc_result = await get_result(
548563
rabbitmq_rpc_client=rabbitmq_rpc_client,
549564
rpc_namespace=STORAGE_RPC_NAMESPACE,
@@ -552,6 +567,7 @@ async def get_async_job_result(request: web.Request) -> web.Response:
552567
user_id=_req_ctx.user_id, product_name=_req_ctx.product_name
553568
),
554569
)
570+
555571
return create_data_response(
556572
StorageAsyncJobResult.from_rpc_schema(async_job_rpc_result),
557573
status=status.HTTP_200_OK,

0 commit comments

Comments
 (0)