Skip to content
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

Add attributes types in SavedObjects migration #64748

Closed
3 of 9 tasks
pgayvallet opened this issue Apr 29, 2020 · 5 comments
Closed
3 of 9 tasks

Add attributes types in SavedObjects migration #64748

pgayvallet opened this issue Apr 29, 2020 · 5 comments
Labels
chore Feature:Saved Objects impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture

Comments

@pgayvallet
Copy link
Contributor

pgayvallet commented Apr 29, 2020

In #63943 we added generic types for SavedObjectMigrationFn input and output doc attributes. As these attributes were previously typed as any, some explicit <any, any> were added in existing plugins migrations as a temporary measure.

Now that SavedObjectMigrationFn allows type checking, the existing migrations should leverage it to ensure that migrated docs are correctly typed.

The initial PR introduced<any, any> changes in the following files:

@elastic/kibana-app

  • src/plugins/vis_type_timeseries/server/saved_objects/tsvb_telemetry.ts
  • x-pack/plugins/graph/server/saved_objects/migrations.ts
  • x-pack/plugins/lens/server/migrations.ts

@elastic/kibana-presentation

  • src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts
  • src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts

@elastic/kibana-app-arch

  • src/plugins/visualizations/server/saved_objects/visualization_migrations.ts
  • src/plugins/data/server/saved_objects/index_pattern_migrations.ts
  • src/plugins/data/server/saved_objects/search_migrations.ts

@elastic/kibana-security

  • x-pack/plugins/spaces/server/saved_objects/migrations/migrate_6x.ts
@pgayvallet pgayvallet added chore Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Saved Objects Team:Visualizations Visualization editors, elastic-charts and infrastructure Team:AppArch labels Apr 29, 2020
@kibanamachine kibanamachine added this to To triage in kibana-app-arch Apr 29, 2020
@wylieconlon
Copy link
Contributor

@pgayvallet @rudolf I've found some issues with the typings that exist that actually prevent us from making these changes in migrations like Lens. I've created a typescript sandbox link which shows why this is currently not possible.

Here are the issues:

  • Each migration function should have slightly different parameters as input, to handle the different versions of the saved object. For example, a migration might create a new property or make a property optional.
  • We can't use the Record<string, SavedObjectMigrationFn type because of "can't assign to unknown" issues
  • We can't use the SavedObjectMigrationMap type because it is not parametrized
  • This implies that the only solution is to type the migration functions as any, or to change something else about how we assign these

@pgayvallet
Copy link
Contributor Author

@wylieconlon your link to the sandbox is incorrect, it's just pointing to https://www.typescriptlang.org/play/index.htm

@wylieconlon
Copy link
Contributor

Sorry, here is the correct link.

@pgayvallet
Copy link
Contributor Author

I forgot to change the SavedObjectMigrationMap type to allow any type of migration.

The type should be:

SavedObjectMigrationMap {
  [version: string]: SavedObjectMigrationFn<any, any>;
}

Created #65569

@timroes timroes added the technical debt Improvement of the software architecture and operational architecture label Nov 4, 2020
@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 21, 2021
@legrego legrego removed Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! EnableJiraSync labels Aug 11, 2022
@pgayvallet
Copy link
Contributor Author

No longer relevant - closing

kibana-app-arch automation moved this from To triage to Done in current release Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:Saved Objects impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture
Projects
kibana-app-arch
  
Done in current release
Development

No branches or pull requests

5 participants