From 6b08e85155d98087c23e802da6645c0fe8f8b2b8 Mon Sep 17 00:00:00 2001 From: Nicolas Pavie Date: Wed, 17 Apr 2024 12:31:30 +0200 Subject: [PATCH] fix(#198): empty value and error handling fix - Dereference the stylesheet parameter as in error with the stylesheet-parameters endpoint error : The error can come from the input also. - Avoid sending empty values to stylesheet parameter endpoint (like in the case of removing the stylesheet parameter value of the form) --- src/main/data/middlewares/pipeline.ts | 33 ++++++++++--------- .../jobToStylesheetParametersXml.ts | 4 ++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/data/middlewares/pipeline.ts b/src/main/data/middlewares/pipeline.ts index 878547e..b63e748 100644 --- a/src/main/data/middlewares/pipeline.ts +++ b/src/main/data/middlewares/pipeline.ts @@ -764,6 +764,7 @@ export function pipelineMiddleware({ getState, dispatch }) { pipelineAPI .fetchStylesheetParameters(job)(webservice) .then((parameters: ScriptOption[] | JobRequestError) => { + error('Result was', parameters) // check if parameters is of type JobRequestError if ('type' in parameters) { dispatch( @@ -774,12 +775,13 @@ export function pipelineMiddleware({ getState, dispatch }) { status: JobStatus.ERROR, }, jobRequestError: parameters, - errors: [ - { - fieldName: 'stylesheet', - error: parameters.description, - }, - ], + // Note : the error can also come from the input + // errors: [ + // { + // fieldName: 'stylesheet', + // error: parameters.description, + // }, + // ], }) ) } else { @@ -828,15 +830,16 @@ export function pipelineMiddleware({ getState, dispatch }) { description: String(e) + ':' + e.parsedText, trace: (e as Error).stack, }, - errors: [ - { - fieldName: 'stylesheet', - error: - e instanceof ParserException - ? e.parsedText - : String(e), - }, - ], + // Note : the error can also come from the input + // errors: [ + // { + // fieldName: 'stylesheet', + // error: + // e instanceof ParserException + // ? e.parsedText + // : String(e), + // }, + // ], }) ) }) diff --git a/src/shared/parser/pipelineXmlConverter/jobToStylesheetParametersXml.ts b/src/shared/parser/pipelineXmlConverter/jobToStylesheetParametersXml.ts index 9517344..16e8183 100644 --- a/src/shared/parser/pipelineXmlConverter/jobToStylesheetParametersXml.ts +++ b/src/shared/parser/pipelineXmlConverter/jobToStylesheetParametersXml.ts @@ -30,7 +30,9 @@ function jobToStylesheetParametersXml(j: Job): string { ${ stylesheet && stylesheet.value ? Array.isArray(stylesheet.value) - ? stylesheet.value.map((v) => ``).join('') + ? stylesheet.value + .map((v) => (v !== '' ? `` : '')) + .join('') : `` : '' }