fix(utils): return all harbor API error messages instead of just the …#859
Closed
DivyanshuVortex wants to merge 1 commit into
Closed
fix(utils): return all harbor API error messages instead of just the …#859DivyanshuVortex wants to merge 1 commit into
DivyanshuVortex wants to merge 1 commit into
Conversation
…first one Signed-off-by: DivyanshuVorrtex <divyanshuchandra9027@gmail.com>
Collaborator
|
@DivyanshuVortex Thank you for this PR. However, there is already work on a package for centralized error handling in PR #636 and #780. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Author
|
Hey @qcserestipy , thnx for your time |
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.
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
ParseHarborErrorMsgutility 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.
Changes
ParseHarborErrorMsginpkg/utils/error.goto safely aggregate and join all returned API error messages.pkg/utils/error_test.goto provide 100% test coverage forParseHarborErrorMsgandParseHarborErrorCode.