fix(utils,prompt): enhance error parsing and goroutine error handling#652
fix(utils,prompt): enhance error parsing and goroutine error handling#652qcserestipy wants to merge 5 commits intogoharbor:mainfrom
Conversation
## Fix goroutine deadlocks and improve error handling in prompt and utils ### Problem - Goroutines were deadlocking when API calls failed because channels were not properly handled on error paths - Error parsing for HTTP status codes (e.g., 403) was incomplete - Missing error returns in functions that only returned values ### Changes - Enhanced `ParseHarborErrorCode()` to properly extract status codes from error messages - Fixed `GetRobotIDFromUser()` to close channels and return errors on failure - Updated `GetRobotPermissionsFromUser()` to handle errors through result channel instead of fataling - All prompt functions now properly propagate errors to callers Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
7ba51d0 to
c8c305c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #652 +/- ##
=========================================
- Coverage 10.99% 7.12% -3.87%
=========================================
Files 173 260 +87
Lines 8671 12948 +4277
=========================================
- Hits 953 922 -31
- Misses 7612 11918 +4306
- Partials 106 108 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes goroutine deadlocks and improves error handling across the codebase. The primary issue was that goroutines using channels would deadlock when API calls failed because error paths didn't properly close channels or return errors to callers.
Changes:
- Enhanced error parsing to extract HTTP status codes from various error message formats
- Fixed channel-based functions to return errors instead of deadlocking
- Standardized error messages across user and robot commands
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/utils/error.go | Enhanced ParseHarborErrorCode to handle "(status 403)" format errors |
| pkg/prompt/prompt.go | Fixed GetRobotIDFromUser and GetRobotPermissionsFromUser to return errors and properly close channels |
| cmd/harbor/root/robot/view.go | Changed from Run to RunE and added error handling for prompt functions |
| cmd/harbor/root/robot/list.go | Changed from Run to RunE and added 403 error handling |
| cmd/harbor/root/robot/delete.go | Added error handling for GetRobotIDFromUser calls |
| cmd/harbor/root/robot/create.go | Added error handling for GetRobotPermissionsFromUser calls throughout |
| cmd/harbor/root/robot/update.go | Added error handling for prompt function calls |
| cmd/harbor/root/robot/refresh.go | Added error handling for GetRobotIDFromUser call |
| cmd/harbor/root/user/*.go | Standardized error messages to include "(Project)" prefix |
| cmd/harbor/root/project/robot/*.go | Updated all calls to GetRobotIDFromUser and GetRobotPermissionsFromUser to handle errors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Fix goroutine deadlocks and improve error handling in prompt and utils
Problem
Changes
ParseHarborErrorCode()to properly extract status codes from error messagesGetRobotIDFromUser()to close channels and return errors on failureGetRobotPermissionsFromUser()to handle errors through result channel instead of fataling