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

[Mappings editor] Handle unsupported types #198185

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Oct 29, 2024

Fixes #197592

Summary

This PR fixes the bug where the index Mappings details page crashes if the index has a mapping field with a type that is not recognized in Kibana. We fix this by using getTypeLabelFromField instead of directly fetching the label property of an object that might be undefined - getTypeLabelFromField takes care of this case.

How to test:

  1. Create the following index in Console (it has the unsupported counted_keyword field type):
PUT test
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "log": {
        "type": "text"
      },
      "ids": {
        "type": "counted_keyword"
      }
    }
  }
}
  1. Go to Index Management and click on the index that we just created
  2. Go to Mappings tab
  3. Verify that the page loads correctly
  4. Check that the opening filter and selecting an option doesn't make the page crash.
Screen.Recording.2024-10-29.at.15.07.28.mov

@ElenaStoeva ElenaStoeva added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Mappings Editor Index mappings editor UI backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 29, 2024
@ElenaStoeva ElenaStoeva self-assigned this Oct 29, 2024
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner October 29, 2024 19:01
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@ElenaStoeva ElenaStoeva changed the title Mappings editor/handle unsupported types [Mappings editor] Handle unsupported types Oct 29, 2024
@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 29, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
indexManagement 688.3KB 688.3KB -25.0B

History

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva requested a review from mattkime October 30, 2024 12:38
Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good and work well!

@ElenaStoeva ElenaStoeva merged commit 3c5319f into elastic:main Oct 30, 2024
43 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11599047795

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 30, 2024
Fixes elastic#197592

## Summary

This PR fixes the bug where the index Mappings details page crashes if
the index has a mapping field with a type that is not recognized in
Kibana. We fix this by using `getTypeLabelFromField` instead of directly
fetching the `label` property of an object that might be `undefined` -
`getTypeLabelFromField` takes care of this case.

**How to test:**
1. Create the following index in Console (it has the unsupported
`counted_keyword` field type):
```
PUT test
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "log": {
        "type": "text"
      },
      "ids": {
        "type": "counted_keyword"
      }
    }
  }
}
```
2. Go to Index Management and click on the index that we just created
3. Go to Mappings tab
4. Verify that the page loads correctly
5. Check that the opening filter and selecting an option doesn't make
the page crash.

https://github.com/user-attachments/assets/4a595968-7cd8-4d36-9a53-264a0d5db50f
(cherry picked from commit 3c5319f)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 30, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Mappings editor] Handle unsupported types
(#198185)](#198185)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-30T18:03:36Z","message":"[Mappings
editor] Handle unsupported types (#198185)\n\nFixes
https://github.com/elastic/kibana/issues/197592\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug where the index Mappings details
page crashes if\r\nthe index has a mapping field with a type that is not
recognized in\r\nKibana. We fix this by using `getTypeLabelFromField`
instead of directly\r\nfetching the `label` property of an object that
might be `undefined` -\r\n`getTypeLabelFromField` takes care of this
case.\r\n\r\n**How to test:**\r\n1. Create the following index in
Console (it has the unsupported\r\n`counted_keyword` field
type):\r\n```\r\nPUT test\r\n{\r\n \"mappings\": {\r\n \"properties\":
{\r\n \"@timestamp\": {\r\n \"type\": \"date\"\r\n },\r\n \"log\": {\r\n
\"type\": \"text\"\r\n },\r\n \"ids\": {\r\n \"type\":
\"counted_keyword\"\r\n }\r\n }\r\n }\r\n}\r\n```\r\n2. Go to Index
Management and click on the index that we just created\r\n3. Go to
Mappings tab\r\n4. Verify that the page loads correctly\r\n5. Check that
the opening filter and selecting an option doesn't make\r\nthe page
crash.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/4a595968-7cd8-4d36-9a53-264a0d5db50f","sha":"3c5319f2152cb38333e53dd2cc993aada8a38e34","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Mappings
Editor","v9.0.0","backport:prev-minor","v8.17.0"],"title":"[Mappings
editor] Handle unsupported
types","number":198185,"url":"https://github.com/elastic/kibana/pull/198185","mergeCommit":{"message":"[Mappings
editor] Handle unsupported types (#198185)\n\nFixes
https://github.com/elastic/kibana/issues/197592\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug where the index Mappings details
page crashes if\r\nthe index has a mapping field with a type that is not
recognized in\r\nKibana. We fix this by using `getTypeLabelFromField`
instead of directly\r\nfetching the `label` property of an object that
might be `undefined` -\r\n`getTypeLabelFromField` takes care of this
case.\r\n\r\n**How to test:**\r\n1. Create the following index in
Console (it has the unsupported\r\n`counted_keyword` field
type):\r\n```\r\nPUT test\r\n{\r\n \"mappings\": {\r\n \"properties\":
{\r\n \"@timestamp\": {\r\n \"type\": \"date\"\r\n },\r\n \"log\": {\r\n
\"type\": \"text\"\r\n },\r\n \"ids\": {\r\n \"type\":
\"counted_keyword\"\r\n }\r\n }\r\n }\r\n}\r\n```\r\n2. Go to Index
Management and click on the index that we just created\r\n3. Go to
Mappings tab\r\n4. Verify that the page loads correctly\r\n5. Check that
the opening filter and selecting an option doesn't make\r\nthe page
crash.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/4a595968-7cd8-4d36-9a53-264a0d5db50f","sha":"3c5319f2152cb38333e53dd2cc993aada8a38e34"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198185","number":198185,"mergeCommit":{"message":"[Mappings
editor] Handle unsupported types (#198185)\n\nFixes
https://github.com/elastic/kibana/issues/197592\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug where the index Mappings details
page crashes if\r\nthe index has a mapping field with a type that is not
recognized in\r\nKibana. We fix this by using `getTypeLabelFromField`
instead of directly\r\nfetching the `label` property of an object that
might be `undefined` -\r\n`getTypeLabelFromField` takes care of this
case.\r\n\r\n**How to test:**\r\n1. Create the following index in
Console (it has the unsupported\r\n`counted_keyword` field
type):\r\n```\r\nPUT test\r\n{\r\n \"mappings\": {\r\n \"properties\":
{\r\n \"@timestamp\": {\r\n \"type\": \"date\"\r\n },\r\n \"log\": {\r\n
\"type\": \"text\"\r\n },\r\n \"ids\": {\r\n \"type\":
\"counted_keyword\"\r\n }\r\n }\r\n }\r\n}\r\n```\r\n2. Go to Index
Management and click on the index that we just created\r\n3. Go to
Mappings tab\r\n4. Verify that the page loads correctly\r\n5. Check that
the opening filter and selecting an option doesn't make\r\nthe page
crash.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/4a595968-7cd8-4d36-9a53-264a0d5db50f","sha":"3c5319f2152cb38333e53dd2cc993aada8a38e34"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Mappings Editor Index mappings editor UI release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Index Management] Index mappings details page gets broken from an unsupported data type counted_keyword
4 participants