Description
GetRegistryIdByName() can fail silently in two ways:
It returns (0, nil) when the registry name is not found.
It calls ListRegistries() without a query filter, so lookup depends on paginated results and may miss registries beyond the first page.
This becomes user-visible in harbor registry delete <registry-name> because the command ignores lookup errors and may attempt to delete registry ID 0.
Steps to Reproduce
- Ensure multiple registries exist (enough to trigger pagination)
- Run command:
harbor registry delete
- Observe error
- Lookup may silently fail
- Delete may proceed with registry ID 0
Expected Behavior
- Lookup should use exact-name filtering via query
- Missing registry should return:
registry '' not found
- Delete command should stop immediately if lookup fails
Actual Behavior
- Lookup returns (0, nil) when registry is not found
- Pagination may cause valid registries to be missed
- Delete command may proceed using ID
0
Environment
- OS: (e.g., Linux / macOS / Windows)
- Tool version: (e.g., Harbor CLI version)
- Other relevant details: N/A
Additional Context
Affected files:
Description
GetRegistryIdByName()can fail silently in two ways:It returns
(0, nil)when the registry name is not found.It calls
ListRegistries()without a query filter, so lookup depends on paginated results and may miss registries beyond the first page.This becomes user-visible in
harbor registry delete <registry-name>because the command ignores lookup errors and may attempt to delete registry ID 0.Steps to Reproduce
harbor registry delete
Expected Behavior
registry '' not found
Actual Behavior
0Environment
Additional Context
Affected files:
pkg/api/registry_handler.gocmd/harbor/root/registry/delete.goSimilar issue fixed for users in PR fix(user): resolve missing id parsing and pagination in user executio… #820