Skip to content

[bug]: registry lookup by name can silently fail and delete may use ID 0 #840

@PrasunaEnumarthy

Description

@PrasunaEnumarthy

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

  1. Ensure multiple registries exist (enough to trigger pagination)
  2. Run command:
    harbor registry delete
  3. 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions