From c06fa9eccbcbb1c14be5cbae4438e14a1f38d2fe Mon Sep 17 00:00:00 2001 From: Andrew Twydell Date: Thu, 9 Jan 2025 17:37:44 +0000 Subject: [PATCH] handle getCache returning non-array Signed-off-by: Andrew Twydell --- packages/vsce/CHANGELOG.md | 1 + packages/vsce/src/utils/commandUtils.ts | 2 +- packages/vsce/src/utils/profileManagement.ts | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/vsce/CHANGELOG.md b/packages/vsce/CHANGELOG.md index 325fa1c9..d927292f 100644 --- a/packages/vsce/CHANGELOG.md +++ b/packages/vsce/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente ## Recent Changes - BugFix: Remove create profile gif from readme. [#33](https://github.com/zowe/cics-for-zowe-client/issues/33) +- BugFix: Handle getCache returning non-array. [#178](https://github.com/zowe/cics-for-zowe-client/issues/178) ## `3.2.4` diff --git a/packages/vsce/src/utils/commandUtils.ts b/packages/vsce/src/utils/commandUtils.ts index 559629f9..7220b6e7 100644 --- a/packages/vsce/src/utils/commandUtils.ts +++ b/packages/vsce/src/utils/commandUtils.ts @@ -63,6 +63,6 @@ export function splitCmciErrorMessage(message: any) { return [resp, resp2, respAlt, eibfnAlt]; } -export function toArray(input: T | [T]): [T] { +export function toArray(input: T | T[]): T[] { return Array.isArray(input) ? input : [input]; } diff --git a/packages/vsce/src/utils/profileManagement.ts b/packages/vsce/src/utils/profileManagement.ts index c1be09f9..df6b3543 100644 --- a/packages/vsce/src/utils/profileManagement.ts +++ b/packages/vsce/src/utils/profileManagement.ts @@ -220,12 +220,14 @@ export class ProfileManagement { if (isPlex) { try { const { response } = await getCache(session, { cacheToken: isPlex, nodiscard: false }); - for (const plex of response.records.cicscicsplex || []) { - infoLoaded.push({ - plexname: plex.plexname, - regions: [], - group: false, - }); + if (response.records.cicscicsplex) { + for (const plex of toArray(response.records.cicscicsplex)) { + infoLoaded.push({ + plexname: plex.plexname, + regions: [], + group: false, + }); + } } } catch (error) { window.showErrorMessage(