Description
The replication interactive prompt helpers (GetReplicationPolicyFromUser, GetReplicationExecutionIDFromUser, and GetReplicationTaskIDFromUser) use log.Fatal() internally when API calls fail or return empty payloads. This abruptly terminates the CLI process, preventing graceful error handling and bypassing Cobra's RunE error reporting mechanism.
Steps to Reproduce
- Run command:
harbor replication start (or similar commands like policies update, executions list without passing IDs).
- Trigger an API failure or have an empty list of policies on the server.
- Observe error: The CLI crashes abruptly via
log.Fatal().
Expected Behavior
The prompt helpers should return an error back to the caller command. The caller (Cobra RunE) should then propagate this error idiomatically (e.g. Error: failed to get replication policy: ...) so the CLI exits cleanly with a standard Cobra non-zero exit code.
Actual Behavior
The application terminates immediately with a stack trace or abrupt log message due to log.Fatal().
Environment
- OS: All
- Tool version: Latest main
- Other relevant details: Affects
pkg/prompt/prompt.go and all consuming commands under cmd/harbor/root/replication/.
Description
The replication interactive prompt helpers (
GetReplicationPolicyFromUser,GetReplicationExecutionIDFromUser, andGetReplicationTaskIDFromUser) uselog.Fatal()internally when API calls fail or return empty payloads. This abruptly terminates the CLI process, preventing graceful error handling and bypassing Cobra'sRunEerror reporting mechanism.Steps to Reproduce
harbor replication start(or similar commands likepolicies update,executions listwithout passing IDs).log.Fatal().Expected Behavior
The prompt helpers should return an
errorback to the caller command. The caller (CobraRunE) should then propagate this error idiomatically (e.g.Error: failed to get replication policy: ...) so the CLI exits cleanly with a standard Cobra non-zero exit code.Actual Behavior
The application terminates immediately with a stack trace or abrupt log message due to
log.Fatal().Environment
pkg/prompt/prompt.goand all consuming commands undercmd/harbor/root/replication/.