From cc9036c852cb6c43a60eec419a493bcdd1375e78 Mon Sep 17 00:00:00 2001 From: harshitha-cstk Date: Tue, 18 Aug 2026 13:20:30 +0530 Subject: [PATCH 1/3] fix(bulk-operations): surface errors on console when console logs are off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bulk command failures were silently swallowed when log.showConsoleLogs was disabled — handleAndLogError only reaches the console through the winston error transport, which is silenced in that mode, so the terminal showed nothing on failure (e.g. an invalid stack API key). Print a user-facing error line in BaseBulkCommand.catch() when console logs are off, reusing cliErrorHandler.classifyError so the message matches the friendly text written to the log file. Guarded to avoid double-printing when console logs are on. Ref: DX-10224 Co-Authored-By: Claude Opus 4.8 --- .../src/base-bulk-command.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/contentstack-bulk-operations/src/base-bulk-command.ts b/packages/contentstack-bulk-operations/src/base-bulk-command.ts index 3251e19ab..1eaa5560e 100644 --- a/packages/contentstack-bulk-operations/src/base-bulk-command.ts +++ b/packages/contentstack-bulk-operations/src/base-bulk-command.ts @@ -5,6 +5,8 @@ import { createLogContext, getLogPath, handleAndLogError, + cliErrorHandler, + cliux, FlagInput, getChalk, loadChalk, @@ -663,13 +665,19 @@ export abstract class BaseBulkCommand extends Command { * This includes errors during init, run, and other phases */ async catch(error: Error): Promise { - // Check if this is a DisplayedError (should be shown to user) - // if (error.name === 'DisplayedError') { - // process.exit(1); - // } - // For other errors, use the CLI utilities error handler handleAndLogError(error); + + // handleAndLogError only reaches the console when log.showConsoleLogs is enabled + // (the winston error transport is silenced otherwise), so a failure would leave the + // terminal completely silent when the user has console logs turned off. Print a + // user-facing error line here to fill that gap, guarded so we don't double-print when + // console logs are on and handleAndLogError already emitted the error. + const showConsoleLogs = Boolean(configHandler.get('log')?.showConsoleLogs); + if (!showConsoleLogs) { + const friendlyMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error'; + cliux.print(`Error: ${friendlyMessage}`, { color: 'red' }); + } } abstract run(): Promise; From e93b7bdcf396a0b770e7146ee6b5160ed91d7cac Mon Sep 17 00:00:00 2001 From: harshitha-cstk Date: Tue, 18 Aug 2026 15:16:43 +0530 Subject: [PATCH 2/3] update error msg --- .../contentstack-bulk-operations/src/base-bulk-command.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contentstack-bulk-operations/src/base-bulk-command.ts b/packages/contentstack-bulk-operations/src/base-bulk-command.ts index 1eaa5560e..594f48819 100644 --- a/packages/contentstack-bulk-operations/src/base-bulk-command.ts +++ b/packages/contentstack-bulk-operations/src/base-bulk-command.ts @@ -675,8 +675,8 @@ export abstract class BaseBulkCommand extends Command { // console logs are on and handleAndLogError already emitted the error. const showConsoleLogs = Boolean(configHandler.get('log')?.showConsoleLogs); if (!showConsoleLogs) { - const friendlyMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error'; - cliux.print(`Error: ${friendlyMessage}`, { color: 'red' }); + const errorMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error'; + cliux.print(`Error: ${errorMessage}`, { color: 'red' }); } } From 4156decc4f3094d561fe1fad6febdd179dee82ec Mon Sep 17 00:00:00 2001 From: harshitha-cstk Date: Wed, 19 Aug 2026 16:58:49 +0530 Subject: [PATCH 3/3] fix(bulk-operations): use console-log policy for catch() error visibility Post-merge, the console-log state moved from configHandler.get('log'). showConsoleLogs to the process-wide console-policy module, and the configHandler import was dropped. catch() still referenced configHandler, breaking the build (TS2304). Switch the guard to isConsoleLogEnabled() so the friendly error line still prints on failure when console logs are off, without double-printing when they are on. Matches the convention the rest of the file now follows. Ref: DX-10224 Co-Authored-By: Claude Opus 4.8 --- .../contentstack-bulk-operations/src/base-bulk-command.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-bulk-operations/src/base-bulk-command.ts b/packages/contentstack-bulk-operations/src/base-bulk-command.ts index 09031b917..b67f9862d 100644 --- a/packages/contentstack-bulk-operations/src/base-bulk-command.ts +++ b/packages/contentstack-bulk-operations/src/base-bulk-command.ts @@ -11,6 +11,7 @@ import { getChalk, loadChalk, CLIProgressManager, + isConsoleLogEnabled, } from '@contentstack/cli-utilities'; import config from './config'; @@ -656,13 +657,12 @@ export abstract class BaseBulkCommand extends Command { // For other errors, use the CLI utilities error handler handleAndLogError(error); - // handleAndLogError only reaches the console when log.showConsoleLogs is enabled + // handleAndLogError only reaches the console when the console-log policy is enabled // (the winston error transport is silenced otherwise), so a failure would leave the // terminal completely silent when the user has console logs turned off. Print a // user-facing error line here to fill that gap, guarded so we don't double-print when // console logs are on and handleAndLogError already emitted the error. - const showConsoleLogs = Boolean(configHandler.get('log')?.showConsoleLogs); - if (!showConsoleLogs) { + if (!isConsoleLogEnabled()) { const errorMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error'; cliux.print(`Error: ${errorMessage}`, { color: 'red' }); }