Skip to content

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

@gcharpe1604

Description

@gcharpe1604

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

  1. Run command: harbor replication start (or similar commands like policies update, executions list without passing IDs).
  2. Trigger an API failure or have an empty list of policies on the server.
  3. 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/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions