Skip to content

Commit

Permalink
Fix bug on null description (elastic#162106)
Browse files Browse the repository at this point in the history
## Summary

Closes elastic#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
elastic#162069

<img width="2496" alt="image"
src="https://github.com/elastic/kibana/assets/17003240/481ef105-2efb-47c0-9d06-94f7fddbf703">

(cherry picked from commit 2e1d36a)
  • Loading branch information
stratoula committed Jul 18, 2023
1 parent eca361c commit ee7fcc7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit ee7fcc7

Please sign in to comment.