goharbor / goharbor/harbor-cli

[bug]: Interactive prompt helpers and views crash abruptly or panic on API errors and user aborts

Open
#931 0 comments 0 reactions 0 assignees View on GitHub
bug status/in-progress
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.