Skip to content

Commit

Permalink
fix(#198): empty value and error handling fix
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
NPavie committed Apr 17, 2024
1 parent 47cf3c0 commit 6b08e85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/main/data/middlewares/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand Down Expand Up @@ -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),
// },
// ],
})
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function jobToStylesheetParametersXml(j: Job): string {
<userStylesheets>${
stylesheet && stylesheet.value
? Array.isArray(stylesheet.value)
? stylesheet.value.map((v) => `<file href="${v}"/>`).join('')
? stylesheet.value
.map((v) => (v !== '' ? `<file href="${v}"/>` : ''))
.join('')
: `<file href="${stylesheet.value}"/>`
: ''
}</userStylesheets>
Expand Down

0 comments on commit 6b08e85

Please sign in to comment.