Skip to content

Commit

Permalink
[api] Limit the number of errors in a work to avoid Elastic field lim…
Browse files Browse the repository at this point in the history
…it (#2376)
  • Loading branch information
SamuelHassine committed Sep 21, 2022
1 parent 4c9cc0a commit 5405d9f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opencti-platform/opencti-graphql/src/domain/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ export const reportExpectation = async (user, workId, errorData) => {
ctx._source['completed_number'] = params.completed_number;
ctx._source['completed_time'] = params.now;`;
}
// To avoid maximum string in Elastic (536870888), arbitrary limit the number of errors possible in a work to 5000 (50000 * 50000 < 536870888)
if (errorData) {
const { error, source } = errorData;
sourceScript += 'ctx._source.errors.add(["timestamp": params.now, "message": params.error, "source": params.source]); ';
sourceScript += 'if (ctx._source.errors.length < 5000) { ctx._source.errors.add(["timestamp": params.now, "message": params.error, "source": params.source]); }';
params.source = source;
params.error = error;
}
Expand Down

0 comments on commit 5405d9f

Please sign in to comment.