-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SO migrations: Improves transformation error creation and testing #100297
SO migrations: Improves transformation error creation and testing #100297
Conversation
…an up transform failure message
…an up transform failure message
…ransforms to throw
failedDoc, | ||
error | ||
); | ||
throw new TransformSavedObjectDocumentError(failedTransform, failedDoc, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the raw doc id in migrateRawDocsSafely
and don't need the extra properties.
Doc: failedDoc" | ||
` | ||
); | ||
expect(err.message).toMatchInlineSnapshot(`"Dang diggity!"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the original transformation error message and don't construct one anymore.
@elasticmachine merge upstream |
…v2/transform-failures-test-enhance
f056e34
to
8d81a96
Compare
src/core/server/saved_objects/migrations/core/document_migrator.test.ts
Outdated
Show resolved
Hide resolved
].length | ||
).toEqual(16); | ||
} | ||
await expect(root.start()).rejects.toThrowError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't use the old approach? Reading from the logs adds flakiness (logging nondeterminism, the test depends on the logging format, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I was trying to avoid parsing strings to get the details.
I'll change it back to read from the error message itself if that's more reliable.
"Failed to transform document smelly. Transform: dog:1.2.3 | ||
Doc: {\\"id\\":\\"smelly\\",\\"type\\":\\"dog\\",\\"attributes\\":{},\\"migrationVersion\\":{}}" | ||
`); | ||
expect(error.message).toMatchInlineSnapshot(`"Dang diggity!"`); | ||
expect(error).toBeInstanceOf(TransformSavedObjectDocumentError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mshustov after we've aded in the raw SO doc id in migrateRawDocsSafely
we push the original error and the rawId
on to the array of transformErrors
within migrateRawDocsSafely
. We assert this in migrate_raw_docs.test
.
We also have the rawId
for failed transformations in the final migration error (as part of the reason) that's shown to the end user when a migration fails because of document transformation issues.
I could specifically add an assertion to the integration test to show that we do get the raw id. It would require a bit of string parsing though, because each transform error also contains the stack trace. I'll add one but can't think of a way to make the parsing elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have the rawId for failed transformations in the final migration error (as part of the reason) that's shown to the end user when a migration fails because of document transformation issues.
Do we know rawId value? If so, we can check that a message contains rawId value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know the rawId value?
We don't know the rawId value in document_migrator
, only the uuid
part of it.
…ing from the logs
…v2/transform-failures-test-enhance
...ver/saved_objects/migrationsv2/integration_tests/migration_7_13_0_transform_failures.test.ts
Outdated
Show resolved
Hide resolved
@@ -1184,7 +1177,7 @@ describe('migrations v2 model', () => { | |||
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); | |||
expect(newState.reason.includes('bob:tail')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asserts that we have the raw document id in the error message
src/core/server/saved_objects/migrations/core/document_migrator.test.ts
Outdated
Show resolved
Hide resolved
src/core/server/saved_objects/migrationsv2/integration_tests/corrupt_outdated_docs.test.ts
Outdated
Show resolved
Hide resolved
...ver/saved_objects/migrationsv2/integration_tests/migration_7_13_0_transform_failures.test.ts
Outdated
Show resolved
Hide resolved
...ver/saved_objects/migrationsv2/integration_tests/migration_7_13_0_transform_failures.test.ts
Outdated
Show resolved
Hide resolved
...ver/saved_objects/migrationsv2/integration_tests/migration_7_13_0_transform_failures.test.ts
Outdated
Show resolved
Hide resolved
💚 Build SucceededMetrics [docs]Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: |
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…00297) (#100435) Co-authored-by: Christiane (Tina) Heiligers <[email protected]>
Summary
Enhances the work on saved object migrations done in #96986.
Resolves #99685
Changes/improvements handled:
originalError
's message as the top levelTransformSavedObjectDocumentError
message.extractTransformFailuresReason
to construct the full, final migration failure reason.Checklist
Delete any items that are not applicable to this PR.
For maintainers