From 3fc1e68146173cea1436ec7476fb3a56040301dd Mon Sep 17 00:00:00 2001 From: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:01:04 +0200 Subject: [PATCH] [Lens] fix merging the existing saved object with the new one instead of replacing (#160260) Fixes https://github.com/elastic/kibana/issues/160116 --- .../lens/server/content_management/lens_storage.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/lens/server/content_management/lens_storage.ts b/x-pack/plugins/lens/server/content_management/lens_storage.ts index d40b64bc5c246..0de3fc38d8a07 100644 --- a/x-pack/plugins/lens/server/content_management/lens_storage.ts +++ b/x-pack/plugins/lens/server/content_management/lens_storage.ts @@ -217,19 +217,19 @@ export class LensStorage implements ContentStorage( - SO_TYPE, + + const savedObject = await soClient.create(SO_TYPE, dataToLatest, { id, - dataToLatest, - optionsToLatest - ); + overwrite: true, + ...optionsToLatest, + }); // Validate DB response and DOWN transform to the request version const { value, error: resultError } = transforms.update.out.result.down< LensUpdateOut, LensUpdateOut >({ - item: savedObjectToLensSavedObject(partialSavedObject, true), + item: savedObjectToLensSavedObject(savedObject, true), }); if (resultError) {