From 6cbfdc36ed13e9c5042ddcaa0c2ac3d4e1fb728c Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 14 Jul 2026 17:00:29 +0530 Subject: [PATCH 1/2] fix: prevent TypeError when parsing null object in CLI (#153) --- templates/cli/lib/parser.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/cli/lib/parser.ts b/templates/cli/lib/parser.ts index 01959fbb1d..2b98b82327 100644 --- a/templates/cli/lib/parser.ts +++ b/templates/cli/lib/parser.ts @@ -199,6 +199,7 @@ const maskSensitiveData = ( const filterObject = (obj: JsonObject): JsonObject => { const result: JsonObject = {}; + if (!obj) return result; for (const key of Object.keys(obj)) { const value = obj[key]; if (typeof value === "function") continue; @@ -341,12 +342,12 @@ export const parse = (data: unknown): void => { if (Array.isArray(section.value)) { const sectionTitle = - typeof section.value[0] === "object" + typeof section.value[0] === "object" && section.value[0] !== null ? `${section.key} (${section.value.length})` : section.key; console.log(`${chalk.yellow.bold.underline(sectionTitle)}`); - if (typeof section.value[0] === "object") { + if (typeof section.value[0] === "object" && section.value[0] !== null) { drawTable(section.value, { indent: " ", sectionName: section.key }); } else { drawScalarArray(section.value, { indent: " " }); From 039153234a69b9ab53726171a09c603dcb5b0deb Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 14 Jul 2026 17:07:00 +0530 Subject: [PATCH 2/2] fix: use some() and == null for parser heuristics --- templates/cli/lib/parser.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/cli/lib/parser.ts b/templates/cli/lib/parser.ts index 2b98b82327..e916998d58 100644 --- a/templates/cli/lib/parser.ts +++ b/templates/cli/lib/parser.ts @@ -199,7 +199,7 @@ const maskSensitiveData = ( const filterObject = (obj: JsonObject): JsonObject => { const result: JsonObject = {}; - if (!obj) return result; + if (obj == null) return result; for (const key of Object.keys(obj)) { const value = obj[key]; if (typeof value === "function") continue; @@ -341,13 +341,15 @@ export const parse = (data: unknown): void => { } if (Array.isArray(section.value)) { - const sectionTitle = - typeof section.value[0] === "object" && section.value[0] !== null + const hasObjects = section.value.some( + (item) => item !== null && typeof item === "object", + ); + const sectionTitle = hasObjects ? `${section.key} (${section.value.length})` : section.key; console.log(`${chalk.yellow.bold.underline(sectionTitle)}`); - if (typeof section.value[0] === "object" && section.value[0] !== null) { + if (hasObjects) { drawTable(section.value, { indent: " ", sectionName: section.key }); } else { drawScalarArray(section.value, { indent: " " });