goharbor / goharbor/harbor-cli

[bug]: harbor webhook list cmd renders both interactive ui and json when format specified is json

Open Beginner friendly
#1,098 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
163
Forks
211
Avg merge
1m
Merged PRs (30d)
1

Description

## Description
When running `harbor webhook list [PROJECT_NAME]` with the `--output-format` flag (e.g., `-o json`), the command outputs the requested formatted JSON and then immediately proceeds to render the interactive Bubble Tea table UI directly below it.

## Steps to Reproduce
1. Run command: `harbor webhook list --output-format json`
2. With arguments/config: valid project name with at least one webhook policy configured
3. Observe error: raw JSON is output, followed immediately by the interactive table view underneath it

## Expected Behavior
When `--output-format` (e.g. `json`, `yaml`, `csv`) is specified, only the requested formatted data stream should be printed to stdout.

## Actual Behavior
The formatted JSON is printed to stdout, followed immediately by the interactive Bubble Tea table UI rendering underneath it.

## Environment
- OS: Linux / All
- Tool version: current `main`
- Other relevant details: tested on local Harbor v2.15.2 instance

## Additional Context
In `cmd/harbor/root/webhook/list.go`, `webhookViews.ListWebhooks(resp.Payload)` is currently called unconditionally outside of the `output-format` check:

```go
FormatFlag := viper.GetString("output-format")
if FormatFlag != "" {
err = utils.PrintFormat(resp, FormatFlag)
if err != nil {
return fmt.Errorf("failed to print in %s format: %v", FormatFlag, err)
}
}
webhookViews.ListWebhooks(resp.Payload)
return nil

Contributor guide

Open the contributing guide

Research direction

Start in cmd/harbor/root/webhook/list.go and trace the output-format branch around utils.PrintFormat and webhookViews.ListWebhooks. Reproduce harbor webhook list --output-format json, then verify that JSON, YAML, or CSV output does not also launch the interactive table UI and that the command still works without a format flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.