Fix bug on null description (#162106)

## Summary

Closes https://github.com/elastic/kibana/issues/162069

Fixes the validation error on the content management service if the
description is set to null.

I am not sure how the description can be set to null. If I create a Lens
so in 7.17 and I don't set the description then it is automatically set
to '' (empty string)

I can think of 2 ways:
- It was possible in older kibana versions
- Someone changed the SO manually and set this to null

This change fixes it with allowing the schema to also set nullable
values.

Note: Maybe covers the undefined case.

To test it just import the SO given by Bhavya here
https://github.com/elastic/kibana/issues/162069

<img width="2496" alt="image"
src="481ef105-2efb-47c0-9d06-94f7fddbf703">
This commit is contained in:
Stratoula Kalafateli 2023-07-18 12:08:34 +03:00 committed by GitHub
parent 0516caed1d
commit 2e1d36a10a
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()),