Problem
GetRegistryIdByName returns (0, nil) when no registry matches the provided name.
At this point err is already nil, so callers interpret the result as success and continue operating on registry ID 0.
Impact
Commands like:
harbor registry delete does-not-exist
silently call:
instead of returning a user-facing error.
This creates:
- confusing UX
- silent invalid API requests
- potential wrong-resource operations
Affected Areas
cmd/harbor/root/registry/delete.go
cmd/harbor/root/registry/update.go
cmd/harbor/root/replication/policies/create.go
Root Cause
GetRegistryIdByName returns:
after iterating all registries without finding a match.
Since err == nil, callers receive (0, nil).
Expected Behavior
When a registry name is not found:
return 0, fmt.Errorf("registry with name %q not found", registryName)
should be returned.
Reproduction
harbor registry delete does-not-exist
Expected:
Error: registry with name "does-not-exist" not found
Actual:
(or Harbor API 404 response)
Proposed Fix
- Return explicit error from
GetRegistryIdByName
- Remove ignored errors (
_) in callers
- Properly propagate errors to users
Problem
GetRegistryIdByNamereturns(0, nil)when no registry matches the provided name.At this point
erris alreadynil, so callers interpret the result as success and continue operating on registry ID0.Impact
Commands like:
silently call:
instead of returning a user-facing error.
This creates:
Affected Areas
cmd/harbor/root/registry/delete.gocmd/harbor/root/registry/update.gocmd/harbor/root/replication/policies/create.goRoot Cause
GetRegistryIdByNamereturns:after iterating all registries without finding a match.
Since
err == nil, callers receive(0, nil).Expected Behavior
When a registry name is not found:
should be returned.
Reproduction
Expected:
Actual:
(or Harbor API 404 response)
Proposed Fix
GetRegistryIdByName_) in callers