[8.9] Fix bug on null description (#162106) (#162121)

# Backport

This will backport the following commits from `main` to `8.9`:
- [Fix bug on null description
(#162106)](https://github.com/elastic/kibana/pull/162106)

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

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

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2023-07-18T09:08:34Z","message":"Fix
bug on null description (#162106)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/162069\r\n\r\nFixes the
validation error on the content management service if the\r\ndescription
is set to null.\r\n\r\nI am not sure how the description can be set to
null. If I create a Lens\r\nso in 7.17 and I don't set the description
then it is automatically set\r\nto '' (empty string)\r\n\r\nI can think
of 2 ways:\r\n- It was possible in older kibana versions\r\n- Someone
changed the SO manually and set this to null\r\n\r\nThis change fixes it
with allowing the schema to also set nullable\r\nvalues.\r\n\r\nNote:
Maybe covers the undefined case.\r\n\r\nTo test it just import the SO
given by Bhavya
here\r\nhttps://github.com/elastic/kibana/issues/162069\r\n\r\n<img
width=\"2496\"
alt=\"image\"\r\nsrc=\"481ef105-2efb-47c0-9d06-94f7fddbf703\">","sha":"2e1d36a10a0f718a59672b21858c430648831322","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:prev-minor","v8.9.0","v8.10.0"],"number":162106,"url":"https://github.com/elastic/kibana/pull/162106","mergeCommit":{"message":"Fix
bug on null description (#162106)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/162069\r\n\r\nFixes the
validation error on the content management service if the\r\ndescription
is set to null.\r\n\r\nI am not sure how the description can be set to
null. If I create a Lens\r\nso in 7.17 and I don't set the description
then it is automatically set\r\nto '' (empty string)\r\n\r\nI can think
of 2 ways:\r\n- It was possible in older kibana versions\r\n- Someone
changed the SO manually and set this to null\r\n\r\nThis change fixes it
with allowing the schema to also set nullable\r\nvalues.\r\n\r\nNote:
Maybe covers the undefined case.\r\n\r\nTo test it just import the SO
given by Bhavya
here\r\nhttps://github.com/elastic/kibana/issues/162069\r\n\r\n<img
width=\"2496\"
alt=\"image\"\r\nsrc=\"481ef105-2efb-47c0-9d06-94f7fddbf703\">","sha":"2e1d36a10a0f718a59672b21858c430648831322"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/162106","number":162106,"mergeCommit":{"message":"Fix
bug on null description (#162106)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/162069\r\n\r\nFixes the
validation error on the content management service if the\r\ndescription
is set to null.\r\n\r\nI am not sure how the description can be set to
null. If I create a Lens\r\nso in 7.17 and I don't set the description
then it is automatically set\r\nto '' (empty string)\r\n\r\nI can think
of 2 ways:\r\n- It was possible in older kibana versions\r\n- Someone
changed the SO manually and set this to null\r\n\r\nThis change fixes it
with allowing the schema to also set nullable\r\nvalues.\r\n\r\nNote:
Maybe covers the undefined case.\r\n\r\nTo test it just import the SO
given by Bhavya
here\r\nhttps://github.com/elastic/kibana/issues/162069\r\n\r\n<img
width=\"2496\"
alt=\"image\"\r\nsrc=\"481ef105-2efb-47c0-9d06-94f7fddbf703\">","sha":"2e1d36a10a0f718a59672b21858c430648831322"}}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
Kibana Machine 2023-07-18 08:06:17 -04:00 committed by GitHub
parent 63549cbc15
commit c522a21d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -29,7 +29,7 @@ const referencesSchema = schema.arrayOf(referenceSchema);
const visualizeAttributesSchema = schema.object(
{
title: schema.string(),
description: schema.maybe(schema.string()),
description: schema.maybe(schema.nullable(schema.string())),
version: schema.maybe(schema.number()),
kibanaSavedObjectMeta: schema.maybe(schema.object({ searchSourceJSON: schema.string() })),
uiStateJSON: schema.maybe(schema.string()),

View file

@ -28,7 +28,7 @@ const referencesSchema = schema.arrayOf(referenceSchema);
const lensAttributesSchema = schema.object(
{
title: schema.string(),
description: schema.maybe(schema.string()),
description: schema.maybe(schema.nullable(schema.string())),
visualizationType: schema.maybe(schema.string()),
state: schema.maybe(schema.any()),
uiStateJSON: schema.maybe(schema.string()),