goharbor / goharbor/harbor-cli

[bug]: ListMembers mutates global columns variable breaking subsequent --wide calls

Open
#1,038 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
163
Forks
211
Avg merge
1m
Merged PRs (30d)
1

Description

## Description
ListMembers in pkg/views/member/list/view.go mutates a package-level `var columns` slice when rendering in non-wide mode. Since it's a global variable, a non-wide call permanently removes columns from it. Every subsequent call — even with --wide — renders an incomplete table.

## Steps to Reproduce
1. Run `harbor project member list --wide` — shows all 6 columns
2. Run `harbor project member list` (non-wide) — shows 4 columns (correct)
3. Run `harbor project member list --wide` again — now shows only 4 columns (broken)

Root cause: line 65 does `columns = utils.RemoveColumns(columns, colsToRemove)` directly on the global.

## Expected Behavior
--wide should always show all 6 columns regardless of previous calls.

## Actual Behavior
After any non-wide call, --wide permanently shows only 4 columns.

## Additional Context
Fix is to make a local copy of the columns slice at function entry and operate on that instead. PR #1002 has the fix ready.

Contributor guide

Open the contributing guide

Research direction

Start in pkg/views/member/list/view.go at ListMembers and reproduce the sequence of --wide, non-wide, then --wide calls. Inspect how the columns slice is handled between calls; done means the final --wide call again renders all 6 columns, with PR #1002 as context.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.