From b63ebae5db73c7b66158e3f026e47c103bf7910a Mon Sep 17 00:00:00 2001 From: harshitha-cstk Date: Mon, 27 Jul 2026 17:28:53 +0530 Subject: [PATCH] fix(bulk-operations): display taxonomy error messages in progress-manager mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In progress-manager mode (log.showConsoleLogs=false) the logger suppresses errors on the console, so bulk-taxonomies failures — including setup errors thrown in init() like "We can't find that Stack" — left a blank screen. Add a surfaceError helper wired into run()'s catch (operation-phase errors) and a catch() override (init-phase errors that never reach run()). It prints the message via cliux only when console logging is suppressed, and skips DisplayedError to avoid duplicating messages validators already print. Co-Authored-By: Claude Opus 4.8 --- .../src/commands/cm/stacks/bulk-taxonomies.ts | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-taxonomies.ts b/packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-taxonomies.ts index 64b5a3e24..1858e132f 100644 --- a/packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-taxonomies.ts +++ b/packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-taxonomies.ts @@ -1,5 +1,5 @@ import { Command } from '@contentstack/cli-command'; -import { flags, log, createLogContext, handleAndLogError, loadChalk } from '@contentstack/cli-utilities'; +import { flags, log, createLogContext, handleAndLogError, loadChalk, configHandler, cliux } from '@contentstack/cli-utilities'; import messages, { $t } from '../../../messages'; import { BaseBulkCommand } from '../../../base-bulk-command'; @@ -116,11 +116,39 @@ export default class BulkTaxonomies extends BaseBulkCommand { this.printOperationSummary(result); } catch (error) { handleAndLogError(error); + this.surfaceError(error); } finally { await this.finally(undefined); } } + /** + * Taxonomy stack/env validation errors are thrown in init() (setupStack) and reach oclif's + * catch() rather than run(). In progress-manager mode the console logger is suppressed + * (log.showConsoleLogs === false), so handleAndLogError writes only to the log file and the + * user sees nothing. Surface the message on the console here, then delegate to the base handler. + */ + async catch(error: Error): Promise { + await super.catch(error); + this.surfaceError(error); + } + + /** + * Print an error to the console when progress-manager mode has suppressed console logging. + * No-op when console logging is enabled (the logger already printed it) or for DisplayedError + * (validators print those directly, so printing again would duplicate them). + */ + private surfaceError(error: unknown): void { + if (error instanceof Error && error.name === 'DisplayedError') { + return; + } + const showConsoleLogs = configHandler.get('log')?.showConsoleLogs; + if (!showConsoleLogs) { + const message = error instanceof Error ? error.message : String(error); + cliux.print(`Error: ${message}`); + } + } + protected async fetchTaxonomies(): Promise { const parsed = this.parsedFlags; const itemsStr = String(parsed.taxonomies || '').trim();