[8.6] [File data visualizer] fix mappings parsing when missing properties (#146109) (#146178)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[File data visualizer] fix mappings parsing when missing properties
(#146109)](https://github.com/elastic/kibana/pull/146109)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"James
Gowdy","email":"jgowdy@elastic.co"},"sourceCommit":{"committedDate":"2022-11-23T15:58:42Z","message":"[File
data visualizer] fix mappings parsing when missing properties
(#146109)\n\nWhen attempting to read the time field from the mappings,
we are\r\nassuming the `properties` key exists. If it doesn't the import
fails.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/146027","sha":"e32f508c90e6a36ddfac3f0d6c0058121e06b841","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix",":ml","Feature:File
Data
Viz","v8.6.0","v8.7.0"],"number":146109,"url":"https://github.com/elastic/kibana/pull/146109","mergeCommit":{"message":"[File
data visualizer] fix mappings parsing when missing properties
(#146109)\n\nWhen attempting to read the time field from the mappings,
we are\r\nassuming the `properties` key exists. If it doesn't the import
fails.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/146027","sha":"e32f508c90e6a36ddfac3f0d6c0058121e06b841"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146109","number":146109,"mergeCommit":{"message":"[File
data visualizer] fix mappings parsing when missing properties
(#146109)\n\nWhen attempting to read the time field from the mappings,
we are\r\nassuming the `properties` key exists. If it doesn't the import
fails.\r\n\r\nFixes
https://github.com/elastic/kibana/issues/146027","sha":"e32f508c90e6a36ddfac3f0d6c0058121e06b841"}}]}]
BACKPORT-->

Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-23 12:09:03 -05:00 committed by GitHub
parent 3a2197c8bb
commit 30c042f34d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@ import {
import { i18n } from '@kbn/i18n';
import { debounce } from 'lodash';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { ResultsLinks } from '../../../common/components/results_links';
import { FilebeatConfigFlyout } from '../../../common/components/filebeat_config_flyout';
import { ImportProgress, IMPORT_STATUS } from '../import_progress';
@ -206,7 +207,7 @@ export class ImportView extends Component {
// mappings, use this field as the time field.
// This relies on the field being populated by
// the ingest pipeline on ingest
if (mappings.properties[DEFAULT_TIME_FIELD] !== undefined) {
if (isPopulatedObject(mappings.properties, [DEFAULT_TIME_FIELD])) {
timeFieldName = DEFAULT_TIME_FIELD;
this.setState({ timeFieldName });
}