Skip to content

fix(registry): return error on failed name lookup and handle it in delete#851

Closed
madmecodes wants to merge 1 commit into
goharbor:mainfrom
madmecodes:fix/registry-lookup-by-name
Closed

fix(registry): return error on failed name lookup and handle it in delete#851
madmecodes wants to merge 1 commit into
goharbor:mainfrom
madmecodes:fix/registry-lookup-by-name

Conversation

@madmecodes
Copy link
Copy Markdown

Closes #840

Two bugs in GetRegistryIdByName:

  1. Returns (0, nil) when the registry name isn't found, so callers
    can't distinguish "not found" from success. Fixed to return
    fmt.Errorf("registry '<name>' not found").

  2. Calls ListRegistries with empty opts, so the lookup only checks
    the default page. Now passes the name filter so the API handles
    filtering server-side.

Also fixed registry delete to:

  • Actually check the error from GetRegistryIdByName instead of
    discarding it with _
  • Try strconv.ParseInt first so numeric IDs work as arguments too

Same pattern as the user lookup fix in #820.

…lete

Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@qcserestipy qcserestipy added the duplicate This issue or pull request already exists label May 3, 2026
@qcserestipy
Copy link
Copy Markdown
Collaborator

qcserestipy commented May 3, 2026

This is a duplicate of #841, this will be decided on later.

EDIT: Also please fix linting issues.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.00%. Comparing base (60ad0bd) to head (457c646).
⚠️ Report is 146 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/registry/delete.go 0.00% 9 Missing ⚠️
pkg/api/registry_handler.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #851      +/-   ##
=========================================
- Coverage   10.99%   9.00%   -1.99%     
=========================================
  Files         173     272      +99     
  Lines        8671   13449    +4778     
=========================================
+ Hits          953    1211     +258     
- Misses       7612   12123    +4511     
- Partials      106     115       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@madmecodes
Copy link
Copy Markdown
Author

Closing - duplicates #841.

@madmecodes madmecodes closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants