Skip to content

pkg/api: paginate all repos in DeleteProject --force#1011

Open
Priyanshubhartistm wants to merge 1 commit into
goharbor:mainfrom
Priyanshubhartistm:fix/delete-project-force-paginate-all-repos
Open

pkg/api: paginate all repos in DeleteProject --force#1011
Priyanshubhartistm wants to merge 1 commit into
goharbor:mainfrom
Priyanshubhartistm:fix/delete-project-force-paginate-all-repos

Conversation

@Priyanshubhartistm

Copy link
Copy Markdown

Description

ListRepository was called once with no pagination opts inside DeleteProject --force, so the Harbor API defaulted to page_size=10. Projects with more than 10 repositories had only the first page deleted, causing the subsequent DeleteProject API call to return 412 Precondition Failed - leaving remaining repositories orphaned.

This fix replaces the single ListRepository call with a paginated loop using page_size=100 that advances page-by-page until all repositories are deleted, before attempting project deletion.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Replaced single ListRepository call with a paginated loop in DeleteProject (pkg/api/project_handler.go)
  • Loop uses page_size=100 (API maximum) and increments page until fewer than 100 results are returned
  • No behaviour change for projects with ≤10 repositories

ListRepository was called once with no opts, so the Harbor API
defaulted to page_size=10. Projects with more than 10 repos had
only the first page deleted, causing DeleteProject to return 412.

Replace the single call with a loop over pages of 100 until all
repositories are deleted before attempting project deletion.

Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: harbor project delete --force only deletes repos from the first API page — projects with >100 repos fail to delete

1 participant