Skip to content

fix(cmd): return errors from PrintFormat in list and info commands - #1101

Open
TaichKarna wants to merge 1 commit into
goharbor:mainfrom
TaichKarna:fix/return-output-format-errors
Open

TaichKarna wants to merge 1 commit into
goharbor:mainfrom
TaichKarna:fix/return-output-format-errors

Conversation

@TaichKarna

Copy link
Copy Markdown

Description

This pull request ensures that formatting errors returned by utils.PrintFormat() (e.g. when an invalid value is supplied to --output-format) are properly propagated by Cobra RunE handlers rather than swallowed.

Previously, these commands used log.Error(err) and returned nil, causing the CLI to log the error but exit with status code 0. Returning the error ensures the CLI exits with a non-zero status code so shell scripts and CI/CD pipelines can detect execution failures.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Propagated formatting errors by replacing log.Error(err) with return err upon utils.PrintFormat() failures across:
    • cmd/harbor/root/info.go
    • cmd/harbor/root/labels/list.go
    • cmd/harbor/root/registry/list.go
    • cmd/harbor/root/repository/list.go
    • cmd/harbor/root/user/list.go

Signed-off-by: TaichKarna <taichikarna@gmail.com>
@TaichKarna
TaichKarna force-pushed the fix/return-output-format-errors branch from be0e322 to 1a16997 Compare September 14, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Invalid --output-format returns exit code 0

1 participant