Skip to content

Commit 341d500

Browse files
authored
Fix saving index pattern when there is a conflict (#21947)
1 parent e49d5f3 commit 341d500

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ui/public/index_patterns/__tests__/_index_pattern.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ jest.mock('../../saved_objects', () => {
9999
update: async (type, id, body, { version }) => {
100100
if (object._version !== version) {
101101
throw {
102-
statusCode: 409
102+
res: {
103+
status: 409
104+
}
103105
};
104106
}
105107

@@ -158,6 +160,6 @@ describe('IndexPattern', () => {
158160
result = err;
159161
}
160162

161-
expect(result.statusCode).toBe(409);
163+
expect(result.res.status).toBe(409);
162164
});
163165
});

src/ui/public/index_patterns/_index_pattern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ export function IndexPatternProvider(Private, config, Promise, confirmModalPromi
463463
setVersion(this, _version);
464464
})
465465
.catch(err => {
466-
if (err.statusCode === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
466+
if (_.get(err, 'res.status') === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
467467
const samePattern = new IndexPattern(this.id);
468468
return samePattern.init()
469469
.then(() => {

0 commit comments

Comments
 (0)