Skip to content

Conversation

@AnvayKharb
Copy link

@AnvayKharb AnvayKharb commented Jan 27, 2026

fixed #455
This pull request fixes a recurring issue in the CLI where errors were being logged but execution continued as if nothing went wrong. In several commands, log.Errorf() was used without returning the error, which caused the CLI to proceed with invalid or empty values and fail silently.

To address this, the PR replaces error logging with explicit error returns using fmt.Errorf, ensuring that failures immediately stop execution and are correctly surfaced to the user. To support this flow, affected commands were updated to use Cobra’s RunE instead of Run, which is the recommended pattern when commands can fail.

As part of this cleanup, the unused logrus imports were removed from the affected files, since error reporting is now handled through returned errors rather than logging.

Overall, this change makes CLI behavior more predictable, prevents silent failures, and aligns error handling across commands with standard Cobra and Go best practices.

Several commands were logging errors with log.Errorf() but continuing
execution instead of returning the error. This caused commands to
silently fail and proceed with invalid/empty values.

Fixed files:
- cmd/harbor/root/artifact/delete.go
- cmd/harbor/root/artifact/scan.go
- cmd/harbor/root/artifact/tags.go
- cmd/harbor/root/artifact/view.go
- cmd/harbor/root/repository/delete.go

Changes:
- Convert Run to RunE for proper error handling
- Replace log.Errorf() with return fmt.Errorf() to propagate errors
- Remove unused log imports

Signed-off-by: Anvay <anvaykharb007@gmail.com>
@AnvayKharb
Copy link
Author

please review @bupd

@AnvayKharb AnvayKharb mentioned this pull request Jan 27, 2026
@bupd bupd self-requested a review January 29, 2026 18:26
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.17%. Comparing base (60ad0bd) to head (7c6a592).
⚠️ Report is 82 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/artifact/tags.go 0.00% 17 Missing ⚠️
cmd/harbor/root/artifact/view.go 0.00% 8 Missing ⚠️
cmd/harbor/root/artifact/scan.go 0.00% 5 Missing ⚠️
cmd/harbor/root/repository/delete.go 0.00% 5 Missing ⚠️
cmd/harbor/root/artifact/delete.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #656      +/-   ##
=========================================
- Coverage   10.99%   7.17%   -3.82%     
=========================================
  Files         173     260      +87     
  Lines        8671   12845    +4174     
=========================================
- Hits          953     922      -31     
- Misses       7612   11815    +4203     
- Partials      106     108       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant