fix(retention): return 404 for missing policies#23592
Open
rkthtrifork wants to merge 3 commits into
Open
Conversation
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
rkthtrifork
force-pushed
the
fix/retention-policy-not-found
branch
from
July 21, 2026 10:22
5bed78a to
3ede672
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Updates retention-policy lookup failures to return Harbor’s typed 404 Not Found response.
Changes:
- Wraps missing DAO records as not-found errors.
- Propagates and tests typed errors.
- Documents the API’s
404response.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/pkg/retention/manager.go |
Propagates typed DAO errors. |
src/pkg/retention/manager_test.go |
Verifies not-found classification and message. |
src/pkg/retention/dao/retention.go |
Wraps missing policies as not-found errors. |
src/pkg/retention/dao/retention_test.go |
Tests DAO error behavior. |
api/v2.0/swagger.yaml |
Documents the GET 404 response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to Harbor!
Comprehensive Summary of your change
Return
404 Not Foundwhen requesting a retention policy that does not exist.Previously, the retention DAO returned Beego's raw
orm.ErrNoRows, and the retention manager converted it into an untyped error. Harbor's shared HTTP error responder therefore classified the error as unknown and returned500 Internal Server Error.This change:
NOT_FOUNDerror usingorm.WrapNotFoundError.404response in the API specification.This matches the existing behavior and implementation used by other ID-based resources such as robots and quotas.
Issue being fixed
No existing issue.
Please indicate you've done the following: