Skip to content

fix(replication): propagate interactive prompt errors to prevent abrupt CLI crashes#932

Open
gcharpe1604 wants to merge 1 commit into
goharbor:mainfrom
gcharpe1604:fix/replication-prompt-error-handling
Open

fix(replication): propagate interactive prompt errors to prevent abrupt CLI crashes#932
gcharpe1604 wants to merge 1 commit into
goharbor:mainfrom
gcharpe1604:fix/replication-prompt-error-handling

Conversation

@gcharpe1604
Copy link
Copy Markdown
Contributor

Description

This PR refactors the replication interactive prompt helpers to prevent the CLI from crashing abruptly via log.Fatal() during API failures or empty payloads. Errors are now propagated idiomatically back to the caller, allowing Cobra to handle them and exit cleanly.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Refactored replication prompt helpers (GetReplicationPolicyFromUser, GetReplicationExecutionIDFromUser, GetReplicationTaskIDFromUser) in pkg/prompt/prompt.go to return (int64, error) instead of using log.Fatal().
  • Updated all consumer commands in cmd/harbor/root/replication/ (start, stop, logs, policies, executions) to gracefully handle these errors and bubble them up via Cobra's RunE.
  • Ensures consistent, automation-friendly non-zero exit codes during failures.

Refactored the replication prompt handlers (GetReplicationPolicyFromUser, GetReplicationExecutionIDFromUser, GetReplicationTaskIDFromUser) to return (int64, error) instead of using log.Fatal(). Updated all replication-related commands to handle these errors and bubble them up via Cobra's RunE, ensuring consistent, automation-friendly exit codes instead of abrupt process termination.

Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 0% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.48%. Comparing base (60ad0bd) to head (e41d857).
⚠️ Report is 162 commits behind head on main.

Files with missing lines Patch % Lines
pkg/prompt/prompt.go 0.00% 34 Missing ⚠️
cmd/harbor/root/replication/logs.go 0.00% 13 Missing ⚠️
cmd/harbor/root/replication/stop.go 0.00% 10 Missing ⚠️
cmd/harbor/root/replication/executions/view.go 0.00% 6 Missing ⚠️
cmd/harbor/root/replication/executions/list.go 0.00% 4 Missing ⚠️
cmd/harbor/root/replication/policies/delete.go 0.00% 4 Missing ⚠️
cmd/harbor/root/replication/policies/update.go 0.00% 4 Missing ⚠️
cmd/harbor/root/replication/policies/view.go 0.00% 4 Missing ⚠️
cmd/harbor/root/replication/start.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #932      +/-   ##
=========================================
- Coverage   10.99%   8.48%   -2.51%     
=========================================
  Files         173     288     +115     
  Lines        8671   14501    +5830     
=========================================
+ Hits          953    1230     +277     
- Misses       7612   13154    +5542     
- Partials      106     117      +11     

☔ 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.

[bug]: Replication prompts use log.Fatal causing abrupt CLI crashes on API errors

1 participant