-
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
[Lens] Fix indexpattern checks for missing references #88840
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
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.
Tested on the same example as before and it worked as expected.
// If we're transitioning to another operation, check for "new" incompleteColumns rather | ||
// than "old" saved operation on the layer | ||
const columnFinalRef = | ||
layer.incompleteColumns?.[columnId]?.operationType || column.operationType; | ||
const def = operationDefinitionMap[columnFinalRef]; |
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.
This chunk could cause a merge conflict with my other open PR, but it should be fine to merge as-is and then fix.
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.
But this is unchanged from master
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.
Ok, checked your PR #88916 together with this one and it works as expected in all the various scenarios. So I'll skip to refactor this and approve your so the merge will provide a fix for both issues.
indexPattern?: IndexPattern | ||
): string[] | undefined { | ||
const errors: string[] = Object.entries(layer.columns) | ||
.flatMap(([columnId, column]) => { |
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.
So in terms of style, you're using flatMap
and then filter
as opposed to forEach
- seems fine.
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.
I was just hoping to use a simple .filter(Boolean)
at the end, but Typescript wasn't happy about that., therefore I had to god for an explicit typeguard.
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.
Looks like in x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
the index pattern parameter for getErrorMessage
is still marked as optional, it seems like we pass it in everywhere now so we can make it required, right?
Not all definitions require the |
@dej611 I meant this kibana/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts Line 200 in 86789da
The consumers don't have to use it, but they can be sure it will always be available if they need it. |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
Tested and LGTM - I also checked the case we talked about (problem in a "hidden" dimension ) and it's not correctly propagated. I will open a separate issue for this
@elasticmachine merge upstream |
I've added a couple more fixes in the area while debugging this PR. |
@elasticmachine merge upstream |
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.
I tested and it seems like the error is shown too often:
- Create vis with "moving average of percentile of val"
- Change "val" field to type string
- Go back to Lens (shows as broken as expected)
- Change oepration to "moving average of unique count of val.keyword"
- Still shown as error
Even on recreating this configuration, the dimension is shown as error.
Uncaught error in the logs:
Uncaught (in promise) TypeError: Cannot read property 'getErrorMessage' of undefined
at utils.ts:43
at Array.map (<anonymous>)
at isColumnInvalid (utils.ts:38)
at dimension_panel.tsx:32
at Object.useMemo (kbn-ui-shared-deps.js:375)
at useMemo (kbn-ui-shared-deps.js:353)
at IndexPatternDimensionTrigger (dimension_panel.tsx:32)
at ua (kbn-ui-shared-deps.js:375)
at Ga (kbn-ui-shared-deps.js:375)
at qa (kbn-ui-shared-deps.js:375)
operationDefinition.getErrorMessage && | ||
operationDefinition.getErrorMessage(layer, columnId, indexPattern) | ||
// check also references for errors | ||
const referencesHaveErrors = (column as ReferenceBasedIndexPatternColumn).references |
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.
nit: You don't need to cast here, 'references' in column &&
will do it in a type safe way
return !!( | ||
operationDefinition.getErrorMessage && | ||
operationDefinition.getErrorMessage(layer, columnId, indexPattern) | ||
// check also references for errors |
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.
Fine for now, but note: Once we introduce formula, we have to extend this to follow references through multiple columns, not just a single "hop"
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.
I've refactor that to be in a distinct function, so we could easily change it later.
@flash1293 you are quite right. There was a missing |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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.
I manually tested both cases that you're fixing, and I'm glad you've added some unit tests for these cases. So LGTM!
…y-tests * 'master' of github.com:elastic/kibana: (276 commits) [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675) [CI] Combines Jest test jobs (elastic#85850) [Upgrade Assistant] Migrate server to new es-js client (elastic#89207) Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351) [Vega Docs] Add experimental flag on the vega maps title (elastic#89402) Increase the time needed to locate the save viz toast (elastic#89301) [Enterprise Search] Add links to doc links service (elastic#89260) Fixed regex bug in Safari (elastic#89399) [Lens] Fix indexpattern checks for missing references (elastic#88840) [Lens] Clean up usage collector (elastic#89109) update apm index pattern (elastic#89395) [APM] Upgrade ES client (elastic#86594) Enable v2 so migrations, disable in FTR tests (elastic#89297) [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699) Cleanup OSS code from visualizations wizard (elastic#89092) [APM] Optimize API test order (elastic#88654) Rename conversion function, extract to module scope and add tests. (elastic#89018) [core.logging] Add ops logs to the KP logging system (elastic#88070) chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333) skip flaky suite (elastic#89379) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx # x-pack/test/accessibility/config.ts
…ana into task-manager/shift-on-trend * 'task-manager/shift-on-trend' of github.com:gmmorris/kibana: (74 commits) [Metrics UI] Fix Host Overview boxes in Host Detail page (elastic#89299) [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675) [CI] Combines Jest test jobs (elastic#85850) [Upgrade Assistant] Migrate server to new es-js client (elastic#89207) Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351) [Vega Docs] Add experimental flag on the vega maps title (elastic#89402) Increase the time needed to locate the save viz toast (elastic#89301) [Enterprise Search] Add links to doc links service (elastic#89260) Fixed regex bug in Safari (elastic#89399) [Lens] Fix indexpattern checks for missing references (elastic#88840) [Lens] Clean up usage collector (elastic#89109) update apm index pattern (elastic#89395) [APM] Upgrade ES client (elastic#86594) Enable v2 so migrations, disable in FTR tests (elastic#89297) [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699) Cleanup OSS code from visualizations wizard (elastic#89092) [APM] Optimize API test order (elastic#88654) Rename conversion function, extract to module scope and add tests. (elastic#89018) [core.logging] Add ops logs to the KP logging system (elastic#88070) chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333) ...
This PR was somehow missing a backport. Fixing now. |
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Marco Liberati <dej611@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Fix #88786 , #89141
This PR addresses a regression on the indexpattern checks on the workspace side of the Lens editor.
For some operations, like the
terms
one, theindexpattern
argument was required to perform a full check, and while this was correctly propagated on the dimension panel side, it was omitted when checking in the workspace.This PR fixes this by adding the
indexpattern
as argument (when available).Also a test to check for correct propagation has been added.
Added
While working in the same area for the
full reference
operation fix, I've added also a fix for the #89141 bug.If field is no longer valid it highlights it in the reference editor:
Also the
full reference
operation is now validating against its internal sub-function as well and showing a warning sign in the panel:In case for some reason a saved chart gets into a state where there's a missing field and its saved operation is no longer valid, both fields gets highlighted now:
Checklist