Skip to content

Conversation

@goyalpalak18
Copy link

Description

I ran into a crash when using harbor project member delete --all while my Harbor credentials were expired.

Instead of telling me the request failed, the CLI panicked with a nil pointer dereference. It turns out the DeleteAllMember function was ignoring errors from the API and trying to read the empty response anyway.

This PR fixes that by adding proper error checking. Now, if the API call fails (network timeout, 401, etc.), the CLI will print a readable error message and exit cleanly instead of crashing with a stack trace.

Verification

I reproduced this by simulating a network error during the delete command.

  • Before: CLI panicked with runtime error: invalid memory address.
  • After: CLI printed failed to list members: connection refused and exited with code 1.

Checklist

  • Panic is fixed.
  • Error messages are readable.
  • Verified happy path still works.

@goyalpalak18
Copy link
Author

Hi @bupd! Could you please review this fix for the nil pointer panic? Thanks!

@bupd bupd added the enhancement New feature or request label Jan 29, 2026
@bupd bupd self-requested a review January 29, 2026 18:18
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.17%. Comparing base (60ad0bd) to head (85d12ff).
⚠️ Report is 82 commits behind head on main.

Files with missing lines Patch % Lines
pkg/api/member_handler.go 0.00% 12 Missing ⚠️
cmd/harbor/root/project/member/delete.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #660      +/-   ##
=========================================
- Coverage   10.99%   7.17%   -3.82%     
=========================================
  Files         173     260      +87     
  Lines        8671   12854    +4183     
=========================================
- Hits          953     922      -31     
- Misses       7612   11824    +4212     
- 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.

…anic

Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
@goyalpalak18 goyalpalak18 force-pushed the fix/delete-all-member-nil-pointer branch from 709d696 to 28a10a5 Compare January 30, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants