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

[Lens] Correctly handle references and migrations for filters in saved objects #114482

Closed
flash1293 opened this issue Oct 11, 2021 · 3 comments · Fixed by #120305
Closed

[Lens] Correctly handle references and migrations for filters in saved objects #114482

flash1293 opened this issue Oct 11, 2021 · 3 comments · Fixed by #120305
Assignees
Labels
Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture

Comments

@flash1293
Copy link
Contributor

References

Lens has local code to handle references in filters

references: SavedObjectReference[];

However as the filters part of the saved object is owned by app services, its references should be handled by the provided helpers of the data plugin exported here:

export const extract = (filters: Filter[]) => {

As the injection scheme changes (indexRefName in the Lens code vs index in the data code), a migration has to be added as well to make sure existing Lens visualizations continue to work.

There is one relevant difference between the Lens code and the data code - the former removes the value property because it used to be non-persistable at some point:

As part of this issues it has to be checked whether this is still necessary - if that's the case the logic has to be moved to the data helper.

Migrations

Filters also can be migrated (

export const getAllMigrations = () => {
) - these migrations should be run as part of the regular migration system.
To do this, it's necessary to mix the filter migrations into the regular Lens SO migrations (and the embeddable migrations used by dashboard):

// This migration is run in 7.13.1 for `by value` panels because the 7.13 release window was missed.

An example for how the migration objects can be mixed can be found in the dashboard plugin which has the same problem for embedded by-value panels:

return mergeMigrationFunctionMaps(dashboardMigrations, embeddableMigrations);

@flash1293 flash1293 added the technical debt Improvement of the software architecture and operational architecture label Oct 11, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label Oct 11, 2021
@flash1293 flash1293 added Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Oct 11, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors (Team:VisEditors)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Oct 11, 2021
@drewdaemon drewdaemon self-assigned this Dec 1, 2021
@drewdaemon
Copy link
Contributor

the former removes the value property because it used to be non-persistable at some point

@flash1293 Who/what would have imposed this constraint?

@drewdaemon
Copy link
Contributor

drewdaemon commented Dec 1, 2021

As the injection scheme changes (indexRefName in the Lens code vs index in the data code), a migration has to be added as well to make sure existing Lens visualizations continue to work.

Not sure I understand what purpose this migration would serve since that indexRefName property isn't actually stored in the Lens state or the saved object. Just derived in the selector.

In other words, wouldn't we just need to update the application code to expect index instead of indexRefName when we start using the data plugin's extract function?

Edit: I was mistaken. I see now that it does get saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants