Skip to content

fix(utils): return all harbor API error messages instead of just the …#859

Closed
DivyanshuVortex wants to merge 1 commit into
goharbor:mainfrom
DivyanshuVortex:errors
Closed

fix(utils): return all harbor API error messages instead of just the …#859
DivyanshuVortex wants to merge 1 commit into
goharbor:mainfrom
DivyanshuVortex:errors

Conversation

@DivyanshuVortex
Copy link
Copy Markdown

Description

Currently, when the Harbor API returns multiple validation errors in a single payload (e.g., "Username too short" AND "Invalid password"), the CLI's ParseHarborErrorMsg utility only extracts and displays the very first error message, silently dropping the rest.

This PR fixes this behavior by iterating through the entire error slice and joining all error messages with a semicolon (; ), providing much better visibility to users when multiple validation checks fail. It also introduces comprehensive table-driven tests for these utilities.

Type of Change

Please select the relevant type.

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

Changes

  • Updated ParseHarborErrorMsg in pkg/utils/error.go to safely aggregate and join all returned API error messages.
  • Created pkg/utils/error_test.go to provide 100% test coverage for ParseHarborErrorMsg and ParseHarborErrorCode.
  • Added edge-case testing for the error parser (e.g., handling non-marshalable payloads, invalid JSON formats, and empty slices) using the project's standard table-driven testing pattern.

…first one

Signed-off-by: DivyanshuVorrtex <divyanshuchandra9027@gmail.com>
@qcserestipy
Copy link
Copy Markdown
Collaborator

@DivyanshuVortex Thank you for this PR. However, there is already work on a package for centralized error handling in PR #636 and #780.

@qcserestipy qcserestipy added the wontfix This will not be worked on label May 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 9.23%. Comparing base (60ad0bd) to head (2072a70).
⚠️ Report is 146 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #859      +/-   ##
=========================================
- Coverage   10.99%   9.23%   -1.76%     
=========================================
  Files         173     272      +99     
  Lines        8671   13444    +4773     
=========================================
+ Hits          953    1242     +289     
- Misses       7612   12087    +4475     
- 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.

@qcserestipy qcserestipy added the duplicate This issue or pull request already exists label May 3, 2026
@DivyanshuVortex
Copy link
Copy Markdown
Author

Hey @qcserestipy , thnx for your time

@DivyanshuVortex DivyanshuVortex deleted the errors branch May 3, 2026 12:57
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 wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ParseHarborErrorMsg silently drops multiple API validation errors

2 participants