goharbor / goharbor/harbor-cli
[bug]: Interactive prompt helpers and views crash abruptly or panic on API errors and user aborts
- Dominant language
- Go
- Stars
- 163
- Forks
- 211
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## Description
The replication interactive prompt helpers (`GetReplicationPolicyFromUser`, `GetReplicationExecutionIDFromUser`, and `GetReplicationTaskIDFromUser`) use `log.Fatal()` internally when API calls fail or return empty payloads. Additionally, some replication selection views terminate the process directly using `os.Exit(1)`.
These abrupt exits bypass Cobra's `RunE` error handling mechanism and prevent commands from returning errors gracefully to the caller.
## Steps to Reproduce
1. Run a replication command that triggers an interactive selection (for example, `harbor replication start` without providing an ID).
2. Trigger an API failure or use an environment where no selectable resources exist.
3. Observe that the CLI terminates abruptly instead of returning an error through Cobra.
## Expected Behavior
Prompt helpers and views should return errors back to the caller command. Cobra's `RunE` handlers should propagate those errors and exit cleanly with a standard non-zero exit code.
## Actual Behavior
The application terminates immediately via `log.Fatal()` or `os.Exit(1)` instead of returning an error to the command layer.
## Environment
* OS: All
* Tool version: Latest main
* Other relevant details: Affects replication prompt helpers in `pkg/prompt/prompt.go` and related replication selection views and commands.
Contributor guide
Assessment
This issue has not been assessed yet.