Skip to content

fix(utils,prompt): enhance error parsing and goroutine error handling#652

Open
qcserestipy wants to merge 5 commits intogoharbor:mainfrom
qcserestipy:fix/robot_unpriv_errors
Open

fix(utils,prompt): enhance error parsing and goroutine error handling#652
qcserestipy wants to merge 5 commits intogoharbor:mainfrom
qcserestipy:fix/robot_unpriv_errors

Conversation

@qcserestipy
Copy link
Collaborator

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

## 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>
@qcserestipy qcserestipy force-pushed the fix/robot_unpriv_errors branch from 7ba51d0 to c8c305c Compare January 26, 2026 19:15
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 0% with 141 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.12%. Comparing base (60ad0bd) to head (1402e06).
⚠️ Report is 81 commits behind head on main.

Files with missing lines Patch % Lines
pkg/prompt/prompt.go 0.00% 27 Missing ⚠️
cmd/harbor/root/robot/create.go 0.00% 21 Missing ⚠️
cmd/harbor/root/robot/update.go 0.00% 15 Missing ⚠️
cmd/harbor/root/robot/delete.go 0.00% 13 Missing ⚠️
pkg/utils/error.go 0.00% 12 Missing ⚠️
cmd/harbor/root/robot/view.go 0.00% 11 Missing ⚠️
cmd/harbor/root/project/robot/update.go 0.00% 9 Missing ⚠️
cmd/harbor/root/robot/refresh.go 0.00% 8 Missing ⚠️
cmd/harbor/root/robot/list.go 0.00% 7 Missing ⚠️
cmd/harbor/root/project/robot/delete.go 0.00% 6 Missing ⚠️
... and 3 more
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.
📢 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.

@Vad1mo Vad1mo requested a review from Copilot January 26, 2026 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

qcserestipy and others added 4 commits January 27, 2026 07:46
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>
@Vad1mo Vad1mo requested a review from bupd January 27, 2026 07:19
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.

1 participant