Skip to content

Conversation

@nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Dec 4, 2025

Summary

Fixes issue where Lens panels on a dashboard that have no references, like a vis with ad-hoc dataview (i.e. ES|QL), will blindly add dashboard references. But these references are not always panel-specific thus lens will absorb all dashboard references.

Details

In #239029 we moved the lens references to the server and passed them in the SO under attributes.references until the references can be properly injected into the state itself.

Previously we were filtering the panel references from the dashboard with the references from attributes.references. But with the transforms now being run on the client side code, the dashboard references can be empty, see #239029 (comment). Thus we need to merge these two reference sources.

// match references based on name, so only references associated with this lens panel are injected.
const matchedReferences: Reference[] = [];
if (Array.isArray(typedState.attributes.references)) {
typedState.attributes.references.forEach((serializableRef) => {
const internalReference = serializableRef;
const matchedReference = references.find(
(reference) => reference.name === internalReference.name
);
if (matchedReference) matchedReferences.push(matchedReference);
});
}
typedState.attributes.references = matchedReferences;
return typedState as unknown as EmbeddableStateWithType;

But additionally, the dashboard may pass the transformOut method all the unfiltered raw references when the filter references are empty.

const panelReferences = filteredReferences.length === 0 ? references : filteredReferences;

The solution is to treat the lens attributes.references as the source of truth and only use the dashboard references to update the id on matching references by name and type.

fixes #245283

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@nickofthyme nickofthyme added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// release_note:skip Skip the PR/issue when compiling release notes Feature:Lens Feature:ES|QL ES|QL related features in Kibana backport:version Backport to applied version labels labels Dec 4, 2025
@nickofthyme nickofthyme requested a review from nreese December 4, 2025 22:37
@nickofthyme nickofthyme marked this pull request as ready for review December 5, 2025 18:25
@nickofthyme nickofthyme requested a review from a team as a code owner December 5, 2025 18:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@nickofthyme nickofthyme changed the title [Lens] ES|QL infinite references [Lens] Infinite reference accumulation Dec 5, 2025
@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #6 / EPM Endpoints Rollback APIs Package rollback input package should fail when at least one package policy does not have a previous revision
  • [job] [logs] FTR Configs #6 / EPM Endpoints Rollback APIs Package rollback integration package should fail when at least one package policy does not have a previous revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:ES|QL ES|QL related features in Kibana Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dashboard][lens embeddable] ESQL panel duplicating all references on save

2 participants