From 92ca4afde529fa1f3e106a7fd174eb295765be35 Mon Sep 17 00:00:00 2001 From: luizfelipelaviola Date: Fri, 20 Feb 2026 18:17:24 -0300 Subject: [PATCH] fix: allow success without metrics file --- .../workerHandleProcessingSuccess.service.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/modules/worker/services/workerHandleProcessingSuccess.service.ts b/src/modules/worker/services/workerHandleProcessingSuccess.service.ts index f90c104..34b3a49 100644 --- a/src/modules/worker/services/workerHandleProcessingSuccess.service.ts +++ b/src/modules/worker/services/workerHandleProcessingSuccess.service.ts @@ -57,22 +57,23 @@ class WorkerHandleProcessingSuccessService { message: "Processing not found.", }); - if (!processing.result_file?.id) - throw new AppError({ - key: "@worker_handle_processing_success_service/RESULT_FILE_NOT_FOUND", - message: "Result file not found.", - }); + const hasResultFile = !!processing.result_file?.id; + const hasMetricsFile = !!processing.metrics_file?.id; - if (!processing.metrics_file?.id) + if (!hasResultFile && !hasMetricsFile) throw new AppError({ - key: "@worker_handle_processing_success_service/METRICS_FILE_NOT_FOUND", - message: "Metrics file not found.", + key: "@worker_handle_processing_success_service/NO_OUTPUT_FILES_FOUND", + message: "No output files found.", }); - const files = await Promise.all([ - File.process(processing.result_file), - File.process(processing.metrics_file), - ]); + const filesToValidate = [ + ...(processing.result_file ? [processing.result_file] : []), + ...(processing.metrics_file ? [processing.metrics_file] : []), + ]; + + const files = await Promise.all( + filesToValidate.map(file => File.process(file)), + ); files.forEach(file => { if (