Skip to content

Comments

655 issue handling#659

Open
DhruvTotala wants to merge 1 commit intogoharbor:mainfrom
DhruvTotala:issue-655-error-handling
Open

655 issue handling#659
DhruvTotala wants to merge 1 commit intogoharbor:mainfrom
DhruvTotala:issue-655-error-handling

Conversation

@DhruvTotala
Copy link

This PR fixes issue #655, where some CLI commands continued executing after an error was logged using log.Errorf(). Because the error was not returned, the command would proceed with empty or invalid values, leading to silent and confusing failures.

What has changed:-

  1. Updated affected commands to use RunE instead of Run so errors can be properly returned
  2. Replaced log.Errorf() with fmt.Errorf() and returned the error to stop execution
  3. Removed os.Exit() calls and relied on error propagation instead
  4. Ensured commands fail immediately when an error occurs, preventing invalid state

These changes make the CLI behavior more predictable and align error handling with standard Cobra CLI practices.

Signed-off-by: dhruv <dhruvtotla30@gmail.com>

Fix: return errors instead of continuing after log.Errorf

CLI commands were continuing execution after logging errors,
leading to invalid or empty state. This change ensures errors
are returned immediately and execution stops as expected.

Signed-off-by: Dhruv Totala <dhruvtotla30@gmail.com>
@DhruvTotala DhruvTotala force-pushed the issue-655-error-handling branch from c437ac2 to 9eea30c Compare January 27, 2026 19:36
@AnvayKharb
Copy link

AnvayKharb commented Jan 27, 2026

@DhruvTotala i have opened a pr #656 . why are you opening a new one ?

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.

2 participants