From e051aa3f7ffe0b41ef06ace71caeb72b46908dce Mon Sep 17 00:00:00 2001 From: regexowl Date: Tue, 24 Sep 2024 09:36:36 +0200 Subject: [PATCH] requestMapper: Fix enabled services with firstboot Previously used `.push()` method was limited by non-writable length of the enabled services array, ending up in the following error: ``` Uncaught (in promise) TypeError: can't define array index property past the end of an array with non-writable length ``` This fixes the problem by updating the array via spread operator. Before: when creating an image with Oscap profile with enabled serviced and adding a firstboot script, the Create blueprint button at the Review step threw an error on click. After fix: it's possible to create an image with Oscap profile that includes enabled services and a firstboot script. --- src/Components/CreateImageWizard/utilities/requestMapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/CreateImageWizard/utilities/requestMapper.ts b/src/Components/CreateImageWizard/utilities/requestMapper.ts index 1cc8b8ef..95bf596d 100644 --- a/src/Components/CreateImageWizard/utilities/requestMapper.ts +++ b/src/Components/CreateImageWizard/utilities/requestMapper.ts @@ -472,12 +472,12 @@ const getServices = (state: RootState): Services | undefined => { return undefined; } - const enabledSvcs = services.enabled || []; + let enabledSvcs = services.enabled || []; const includeFBSvc: boolean = !!selectFirstBootScript(state) && !services.enabled?.includes(FIRST_BOOT_SERVICE); if (includeFBSvc) { - enabledSvcs.push(FIRST_BOOT_SERVICE); + enabledSvcs = [...enabledSvcs, FIRST_BOOT_SERVICE]; } return {