Skip to content

fixed the auth error in clone command#198

Open
cs-raj wants to merge 1 commit into
v2-devfrom
fix/DX-5636
Open

fixed the auth error in clone command#198
cs-raj wants to merge 1 commit into
v2-devfrom
fix/DX-5636

Conversation

@cs-raj
Copy link
Copy Markdown
Contributor

@cs-raj cs-raj commented May 31, 2026

Problem

Running cm:stacks:clone while unauthenticated produced no output at all when showConsoleLogs was false (the default after config:set:log --level info).

Expected: ERROR: Please login to execute this command, csdx auth:login
Actual: Silent exit — user has no idea why the command stopped

Root Cause

Two compounding issues in run():

1. progressSupportedModule was set unconditionally at the top of run()

// ❌ Before — ran before any auth check
configHandler.set('log.progressSupportedModule', 'clone');

clone is in PROGRESS_SUPPORTED_MODULES, so setting this put the logger into "progress-bar mode" where showConsoleLogs defaults to false. The Console transport was never added to the winston logger, so log.error(...) only wrote to the log file.

2. Stale value persisted across CLI invocations
configHandler.set writes to an encrypted config file on disk. Once set by any run, the value persisted for all subsequent runs — meaning even commands that never called handleClone() (i.e. auth failures) still started with progressSupportedModule: 'clone' from disk, silencing their error output.


Fix

src/commands/cm/stacks/clone.ts

  • Clear progressSupportedModule to null at the very start of run() — before parse() or any log call — so a fresh logger instance is created without progress-bar mode active.
  • Re-set it to 'clone' as the first line of handleClone() — so progress-bar mode only activates after authentication passes and the actual clone operation begins.
async run(): Promise<void> {
  try {
    // Clear stale value from previous runs — ensures auth errors always reach console
    configHandler.set('log.progressSupportedModule', null);  // ← NEW
    const { flags } = await self.parse(StackCloneCommand);

    const handleClone = async () => {
      configHandler.set('log.progressSupportedModule', 'clone');  // ← MOVED here
      ...
    };

    if (isAuthenticated()) {
      handleClone();
    } else {
      log.error('Please login...');  // ← now always visible
    }
  }
}

Changes

File Change
src/commands/cm/stacks/clone.ts Clear progressSupportedModule at start of run(); move set into handleClone()
test/commands/cm/stacks/clone.test.ts Un-skip and rewrite two auth error tests; add progressSupportedModule assertions

Test Updates

Test Change
should exit when not authenticated and no management token aliases Un-skipped. Stubs configHandler.get to force isAuthenticated() = false, stubs cleanUp, asserts log.error fires with correct message and progressSupportedModule is never set to 'clone'
should exit when management token aliases + branches but not authenticated Un-skipped. Same pattern
should handle run with authenticated user and all optional flags Added assertion that progressSupportedModule IS set to 'clone' inside handleClone after auth passes

Behaviour

Scenario Before After
Not logged in, showConsoleLogs: false Silent exit ERROR: Please login to execute this command
Not logged in, showConsoleLogs: true Error shown Error shown (unchanged)
Logged in, showConsoleLogs: false Progress bars work Progress bars work (unchanged)

@github-actions
Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 3 57 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

⚠️ Warning: The following vulnerabilities have exceeded their SLA thresholds (days since publication).

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 1 90 / 365 days ⚠️ Warning
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 57
  • Medium without fixes: 2
  • Low without fixes: 0

⚠️ BUILD PASSED WITH WARNINGS - SLA breaches detected for issues without available fixes

Consider reviewing these vulnerabilities when fixes become available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants