Skip to content

fix(retention): return 404 for missing policies#23592

Open
rkthtrifork wants to merge 3 commits into
goharbor:mainfrom
rkthtrifork:fix/retention-policy-not-found
Open

fix(retention): return 404 for missing policies#23592
rkthtrifork wants to merge 3 commits into
goharbor:mainfrom
rkthtrifork:fix/retention-policy-not-found

Conversation

@rkthtrifork

@rkthtrifork rkthtrifork commented Jul 21, 2026

Copy link
Copy Markdown

Thank you for contributing to Harbor!

Comprehensive Summary of your change

Return 404 Not Found when 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 returned 500 Internal Server Error.

This change:

  • Wraps missing retention policies with Harbor's standard NOT_FOUND error using orm.WrapNotFoundError.
  • Propagates the typed error through the retention manager.
  • Documents the 404 response in the API specification.
  • Adds DAO and manager assertions covering the error classification and message.

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:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

Copilot AI review requested due to automatic review settings July 21, 2026 10:20
@rkthtrifork
rkthtrifork requested a review from a team as a code owner July 21, 2026 10:20
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
@rkthtrifork
rkthtrifork force-pushed the fix/retention-policy-not-found branch from 5bed78a to 3ede672 Compare July 21, 2026 10:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 404 response.

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.

Comment thread src/pkg/retention/manager_test.go
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Copilot AI review requested due to automatic review settings July 21, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 22, 2026 07:47
@wy65701436 wy65701436 added the release-note/update Update or Fix label Jul 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/update Update or Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants