Skip to content

Commit

Permalink
Fix saving index pattern when there is a conflict (#21947) (#22025)
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang authored Aug 15, 2018
1 parent bb2ec20 commit 524cd5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/ui/public/index_patterns/__tests__/_index_pattern.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ jest.mock('../../saved_objects', () => {
update: async (type, id, body, { version }) => {
if (object._version !== version) {
throw {
statusCode: 409
res: {
status: 409
}
};
}

Expand Down Expand Up @@ -157,6 +159,6 @@ describe('IndexPattern', () => {
result = err;
}

expect(result.statusCode).toBe(409);
expect(result.res.status).toBe(409);
});
});
2 changes: 1 addition & 1 deletion src/ui/public/index_patterns/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export function IndexPatternProvider(Private, config, Promise, confirmModalPromi
setVersion(this, _version);
})
.catch(err => {
if (err.statusCode === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
if (_.get(err, 'res.status') === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
const samePattern = new IndexPattern(this.id);
return samePattern.init()
.then(() => {
Expand Down

0 comments on commit 524cd5c

Please sign in to comment.