-
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
Improve handling of invalid data during migrations #38669
Comments
Pinging @elastic/kibana-platform |
I agree that strictly defining what data we expect and throwing a runtime error if unexpected data appears will improve the quality and readability of the migrations. The same problems you mentioned with not knowing the shape of the input data also filters through to any part of the code base that uses SavedObjects. This would require a bit more work, but I think it could be very valuable if plugins were required to define runtime types using something like https://github.com/gcanti/io-ts to define the shape of their SavedObjects. That would provide a strong guarantee to all consuming code (including migrations) about the shape of the data. |
Thinking more about this... I think we'd probably want to move to something like this slowly. It's my understanding that throwing an error will prevent Kibana from starting up. A client who upgrades from 7.x to 7.x.+1 could potentially suddenly see their Kibana failing to start due to invalid data that was previously ignored. A better plan may be to: 7.x:
8.0:
Benefits:
|
nevermind, regardless, I think it'd be great if migrations could throw errors and the migration system itself would catch those errors, track them somehow, log the error to the console/file, and then continue on with the migrations with a best attempt. |
Background
We currently handle invalid data during migrations inconsistently. Sometimes we throw an error, sometimes we just return the invalid data.
This makes it difficult for us to know what type of data we might be dealing with and increases the chances for migrations errors when our assumptions turn out to be wrong.
Goal
Be able to make assumptions about the shape of our data in any given release.
Proposal
If we start just throwing errors when we encounter unknown data, this could prevent users from upgrading, so we should get there slowly. If we increase our knowledge of the shape of data out in the wild, we should be able to account for that in future migrations until we are finally at a spot we can say we are confident we know the shape of the data.
Related
@spalger - I see we have had similar thoughts!
The text was updated successfully, but these errors were encountered: