goharbor / goharbor/harbor-cli

[bug]: Registry ID Validation (Proxy Cache)

Open
#886 0 comments 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 creating a Proxy Cache project, the CLI fails to validate the `--registry-id` flag. If a non-numeric value is provided, the error is ignored, and the project creation proceeds with a `registryID` of `0`, which can lead to incorrect project configurations or unexpected server errors.

## Steps to Reproduce
1. Run the command: `harbor project create my-proxy --proxy-cache --registry-id "my-registry"`
2. Observe the output: `"Project created successfully"` (even though the Registry ID was invalid).

## Expected Behavior
The CLI should validate that the `--registry-id` is a valid integer before making the API request and return an error if it is not.

## Actual Behavior
The parsing failure is ignored, and a value of `0` is sent to the Harbor API.

## Environment
- **OS:** Any
- **Tool version:** Latest main branch
- **Other relevant details:** Affects logic in `pkg/api/project_handler.go` line 34.

## Additional Context

Image

proof:

Image

as you can see it should've stopped at "abc"

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.