[bug]: Registry ID Validation (Proxy Cache)

Open Beginner friendly
#886 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in pkg/api/project_handler.go around line 34 and reproduce the issue with harbor project create my-proxy --proxy-cache --registry-id "my-registry". Trace how the registry ID is parsed before the API request. Done means a non-numeric value stops project creation with an error instead of sending registryID 0.

Written by the indexing model from the issue text.

Description

bug

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"

Dominant language
Go
Stars
163
Forks
212
Avg merge
1m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from goharbor/harbor-cli

All issues in goharbor/harbor-cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.