From 1c65de4a80f43747257943f224368190a4017a66 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Thu, 23 May 2024 10:23:49 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20target=20patch=20with=5FA?= =?UTF-8?q?liases=20field=20(#2305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/serializers/target.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index 1fec14cdd..1f4dd8cd9 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -23,7 +23,7 @@ export default class TargetSerializer extends ApplicationSerializer { */ serialize(snapshot) { let serialized = super.serialize(...arguments); - const { type } = snapshot.record; + const { type, isNew } = snapshot.record; const hostSourceIDs = snapshot?.adapterOptions?.hostSetIDs; if (hostSourceIDs) { serialized = this.serializeWithHostSources(snapshot, hostSourceIDs); @@ -44,14 +44,16 @@ export default class TargetSerializer extends ApplicationSerializer { injectedApplicationCredentialSourceIDs, ); - if (serialized?.with_aliases) { + if (isNew && serialized?.with_aliases) { // API expects scope id along with every alias value serialized.with_aliases = serialized.with_aliases.map((item) => ({ ...item, scope_id: 'global', })); + } else { + // This field can't be updated, it is used only during creation time + delete serialized.with_aliases; } - // Delete session recording related fields from non-SSH targets if (type !== TYPE_TARGET_SSH) { delete serialized?.attributes?.storage_bucket_id;