Skip to content

Commit

Permalink
Hide 409 errors during signal creation
Browse files Browse the repository at this point in the history
These are expected and potentially confusing to the user. Instead, we
only show unexpected errors.
  • Loading branch information
rylnd committed Jan 2, 2020
1 parent 40dd650 commit 1bcf978
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { countBy } from 'lodash';
import { countBy, isEmpty } from 'lodash';
import { performance } from 'perf_hooks';
import { AlertServices } from '../../../../../alerting/server/types';
import { SignalSearchResponse, BulkResponse } from './types';
Expand Down Expand Up @@ -82,9 +82,9 @@ export const singleBulkCreate = async ({
if (response.errors) {
const itemsWithErrors = response.items.filter(item => item.create.error);
const errorCountsByStatus = countBy(itemsWithErrors, item => item.create.status);
const hasNonDuplicateError = Object.keys(errorCountsByStatus).some(status => status !== '409');
delete errorCountsByStatus['409']; // Duplicate signals are expected

if (hasNonDuplicateError) {
if (!isEmpty(errorCountsByStatus)) {
logger.error(
`[-] bulkResponse had errors with response statuses:counts of...\n${JSON.stringify(
errorCountsByStatus,
Expand Down

0 comments on commit 1bcf978

Please sign in to comment.