Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.8] [Security Solution] getDataViewStateFromIndexFields was using w…
…rong type as part of a cast (#158594) (#158784) # Backport This will backport the following commits from `main` to `8.8`: - [[Security Solution] getDataViewStateFromIndexFields was using wrong type as part of a cast (#158594)](#158594) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kevin Qualters","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-31T21:13:36Z","message":"[Security Solution] getDataViewStateFromIndexFields was using wrong type as part of a cast (#158594)\n\n## Summary\r\n\r\nFixes an issue with the field browser where all types currently display\r\nas unkown, this was because in a code path where a type cast happens, we\r\nwere using the wrong type. To see this, remove the as unknown from the\r\ncast, and the typescript compiler will show the problem:\r\n```\r\n'BrowserField' is deprecated.ts(6385)\r\nindex.ts(70, 4): The declaration was marked as deprecated here.\r\nConversion of type 'DataViewField' to type 'BrowserField' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.\r\n Type 'DataViewField' is missing the following properties from type 'BrowserField': category, description, example, fields, and 2 more.ts(2352)\r\n```\r\nDataViewField actually only has spec and kbnFieldType properties, spec\r\nis of type FieldSpec which is basically the same type as BrowserField,\r\nand has sufficient overlap for the (still unsafe, but more safe than as\r\nunknown) cast to occur.\r\n\r\nBefore:\r\n<img width=\"338\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/f31c1f9e-25f0-41ee-9e1c-a70171e41d29\">\r\n\r\n\r\nAfter:\r\n<img width=\"555\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/8b462477-2dce-41bb-9592-f34b20634b84\">\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1c75903f92b639e2dcffe76ed8b4ef4d6db3b70d","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Threat Hunting:Investigations","v8.9.0","v8.8.1"],"number":158594,"url":"https://github.com/elastic/kibana/pull/158594","mergeCommit":{"message":"[Security Solution] getDataViewStateFromIndexFields was using wrong type as part of a cast (#158594)\n\n## Summary\r\n\r\nFixes an issue with the field browser where all types currently display\r\nas unkown, this was because in a code path where a type cast happens, we\r\nwere using the wrong type. To see this, remove the as unknown from the\r\ncast, and the typescript compiler will show the problem:\r\n```\r\n'BrowserField' is deprecated.ts(6385)\r\nindex.ts(70, 4): The declaration was marked as deprecated here.\r\nConversion of type 'DataViewField' to type 'BrowserField' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.\r\n Type 'DataViewField' is missing the following properties from type 'BrowserField': category, description, example, fields, and 2 more.ts(2352)\r\n```\r\nDataViewField actually only has spec and kbnFieldType properties, spec\r\nis of type FieldSpec which is basically the same type as BrowserField,\r\nand has sufficient overlap for the (still unsafe, but more safe than as\r\nunknown) cast to occur.\r\n\r\nBefore:\r\n<img width=\"338\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/f31c1f9e-25f0-41ee-9e1c-a70171e41d29\">\r\n\r\n\r\nAfter:\r\n<img width=\"555\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/8b462477-2dce-41bb-9592-f34b20634b84\">\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1c75903f92b639e2dcffe76ed8b4ef4d6db3b70d"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158594","number":158594,"mergeCommit":{"message":"[Security Solution] getDataViewStateFromIndexFields was using wrong type as part of a cast (#158594)\n\n## Summary\r\n\r\nFixes an issue with the field browser where all types currently display\r\nas unkown, this was because in a code path where a type cast happens, we\r\nwere using the wrong type. To see this, remove the as unknown from the\r\ncast, and the typescript compiler will show the problem:\r\n```\r\n'BrowserField' is deprecated.ts(6385)\r\nindex.ts(70, 4): The declaration was marked as deprecated here.\r\nConversion of type 'DataViewField' to type 'BrowserField' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.\r\n Type 'DataViewField' is missing the following properties from type 'BrowserField': category, description, example, fields, and 2 more.ts(2352)\r\n```\r\nDataViewField actually only has spec and kbnFieldType properties, spec\r\nis of type FieldSpec which is basically the same type as BrowserField,\r\nand has sufficient overlap for the (still unsafe, but more safe than as\r\nunknown) cast to occur.\r\n\r\nBefore:\r\n<img width=\"338\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/f31c1f9e-25f0-41ee-9e1c-a70171e41d29\">\r\n\r\n\r\nAfter:\r\n<img width=\"555\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/8b462477-2dce-41bb-9592-f34b20634b84\">\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"1c75903f92b639e2dcffe76ed8b4ef4d6db3b70d"}},{"branch":"8.8","label":"v8.8.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information