Skip to content

fix: reject invalid page values in selected list commands#779

Open
PrasunaEnumarthy wants to merge 2 commits intogoharbor:mainfrom
PrasunaEnumarthy:fix/page-validation
Open

fix: reject invalid page values in selected list commands#779
PrasunaEnumarthy wants to merge 2 commits intogoharbor:mainfrom
PrasunaEnumarthy:fix/page-validation

Conversation

@PrasunaEnumarthy
Copy link
Copy Markdown

Description

This pull request adds early validation for invalid --page values in selected list commands.

Previously, some commands accepted invalid values such as --page 0 or negative page numbers and passed them to the API, which could lead to inconsistent behavior.

This change ensures that invalid page values are rejected before making API calls, improving CLI reliability and consistency.

Type of Change

Please select the relevant type.

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

Changes

  • Added validation to reject --page < 1 in:
    • harbor artifact list
    • harbor project list
    • harbor registry list
  • Used the same validation message as harbor project logs for consistency
  • Ensured validation occurs before API calls

@qcserestipy qcserestipy self-requested a review April 1, 2026 17:34
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.79%. Comparing base (60ad0bd) to head (657dbe1).
⚠️ Report is 123 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/artifact/list.go 0.00% 2 Missing ⚠️
cmd/harbor/root/project/list.go 0.00% 2 Missing ⚠️
cmd/harbor/root/registry/list.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #779      +/-   ##
=========================================
- Coverage   10.99%   7.79%   -3.20%     
=========================================
  Files         173     270      +97     
  Lines        8671   13175    +4504     
=========================================
+ Hits          953    1027      +74     
- Misses       7612   12035    +4423     
- Partials      106     113       +7     

☔ 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.

Copy link
Copy Markdown
Collaborator

@qcserestipy qcserestipy left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution and having a look into this. It looks to me that this list of changed commands might not be complete:

Image

Can you please check all commands that contain opts.Page and make sure that all of them are checked properly.

@qcserestipy qcserestipy added the Changes Requesed feedback that must be addressed before merging. label Apr 1, 2026
@PrasunaEnumarthy
Copy link
Copy Markdown
Author

Thanks, I’ll expand the validation to all commands that accept opts.Page and add tests for the new checks.

Signed-off-by: PrasunaEnumarthy <eswari.prasuna@gmail.com>
Signed-off-by: PrasunaEnumarthy <eswari.prasuna@gmail.com>
@PrasunaEnumarthy
Copy link
Copy Markdown
Author

Thanks, I’ve updated the PR to add the '--page >= 1' validation to all commands that define opts.Page, using the same error message as project logs.
I also added tests for the originally changed commands (artifact list, project list, and registry list) and verified them locally with:

go test ./cmd/harbor/root/artifact ./cmd/harbor/root/project ./cmd/harbor/root/registry

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

Labels

Changes Requesed feedback that must be addressed before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Reject invalid page values in artifact, project, and registry list commands

2 participants