Skip to content

Commit

Permalink
Error message format changes and updates to snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed May 6, 2021
1 parent 9bb9ec1 commit 22a6ca3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('migration v2', () => {
await root.setup();

await expect(root.start()).rejects.toThrow(
'Unable to complete saved object migrations for the [.kibana] index: Migrations failed. Reason: The following saved object documents are corrupt: index-pattern:test_index* . To allow migrations to proceed, please delete these documents.'
'Unable to complete saved object migrations for the [.kibana] index: Migrations failed. Reason: Corrupt saved object documents: index-pattern:test_index*. To allow migrations to proceed, please delete these documents.'
);

const logFileContent = await asyncReadFile(logFilePath, 'utf-8');
Expand Down
9 changes: 4 additions & 5 deletions src/core/server/saved_objects/migrationsv2/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,9 @@ describe('migrations v2 model', () => {
});
const newState = model(testState, res) as FatalState;
expect(newState.controlState).toBe('FATAL');
expect(newState.reason).toMatchInlineSnapshot(`
"Migrations failed. Reason: Corrupt saved object documents: a:b.
. To allow migrations to proceed, please delete these documents."
`);
expect(newState.reason).toMatchInlineSnapshot(
`"Migrations failed. Reason: Corrupt saved object documents: a:b. To allow migrations to proceed, please delete these documents."`
);
});
});

Expand Down Expand Up @@ -1069,7 +1068,7 @@ describe('migrations v2 model', () => {
};
const newState = model(transformErrorsState, res) as FatalState;
expect(newState.controlState).toBe('FATAL');
expect(newState.reason.includes('Migrations failed. Reason: ')).toBe(true);
expect(newState.reason.includes('Migrations failed. Reason:')).toBe(true);
expect(newState.reason.includes('Corrupt saved object documents: ')).toBe(true);
expect(newState.reason.includes('Transformation errors: ')).toBe(true);
expect(newState.reason.includes('randomvis: 7.12.0')).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/migrationsv2/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function extractTransformFailuresReason(
): { corruptDocsReason: string; transformErrsReason: string } {
const corruptDocumentIdReason =
corruptDocumentIds.length > 0
? ` Corrupt saved object documents: ${corruptDocumentIds.join(',')}.\n`
? `Corrupt saved object documents: ${corruptDocumentIds.join(',')}.`
: ' ';
// we have both the saved object Id and the stack trace in each `transformErrors` item.
const transformErrorsReason =
Expand Down Expand Up @@ -534,7 +534,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
return {
...stateP,
controlState: 'FATAL',
reason: `Migrations failed. Reason: ${corruptDocsReason} ${transformErrsReason}. To allow migrations to proceed, please delete these documents.`,
reason: `Migrations failed. Reason: ${corruptDocsReason} ${transformErrsReason} To allow migrations to proceed, please delete these documents.`,
};
} else {
// we don't have any more outdated documents and we haven't encountered any document transformation issues.
Expand Down

0 comments on commit 22a6ca3

Please sign in to comment.