From 74baf9ab564e4338148ee14f6c770bc7ad9b5676 Mon Sep 17 00:00:00 2001 From: jpkha Date: Tue, 27 Feb 2024 15:45:16 +0100 Subject: [PATCH] [backend] fix workflow_id throw error (#6139) --- opencti-platform/opencti-graphql/src/database/engine.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opencti-platform/opencti-graphql/src/database/engine.js b/opencti-platform/opencti-graphql/src/database/engine.js index 84682dbee6fd..a360d0bed62d 100644 --- a/opencti-platform/opencti-graphql/src/database/engine.js +++ b/opencti-platform/opencti-graphql/src/database/engine.js @@ -2103,8 +2103,11 @@ const adaptFilterToComputedReliabilityFilterKey = async (context, user, filter) const adaptFilterToWorkflowFilterKey = async (context, user, filter) => { const { key, mode = 'or', operator = 'eq', values } = filter; const arrayKeys = Array.isArray(key) ? key : [key]; - if (arrayKeys[0] !== WORKFLOW_FILTER || arrayKeys[0] !== X_OPENCTI_WORKFLOW_ID || arrayKeys.length > 1) { - throw UnsupportedError(`A filter with these multiple keys is not supported: ${arrayKeys}`); + if (arrayKeys.length > 1) { + throw UnsupportedError(`A filter with these multiple keys is not supported : ${arrayKeys}`); + } + if (!arrayKeys[0].includes(WORKFLOW_FILTER, X_OPENCTI_WORKFLOW_ID)) { + throw UnsupportedError('The key is not correct', { keys: arrayKeys }); } if (operator === 'nil' || operator === 'not_nil') { // no status template <-> no status // at least a status template <-> at least a status return { @@ -2127,7 +2130,7 @@ const adaptFilterToWorkflowFilterKey = async (context, user, filter) => { operator, }; } - throw Error(`The operators supported for a filter with key=workflow_id are: eq, not_eq, nil, not_nil: ${operator} is not supported.`); + throw UnsupportedError('The operators supported for a filter with key=workflow_id is not supported.', { operator }); }; /**