-
Notifications
You must be signed in to change notification settings - Fork 140
Description
Description
When running the password command, the code ignores the error returned by GetCredentials and proceeds with a zero-value credential. UpdateCredentialsInConfigFile then calls log.Fatalf(...) when it cannot find the credential, causing the CLI to exit immediately (hard fatal) instead of returning a controlled error.
Steps to Reproduce
- Run command:
go build -o harbor ./cmd/harbor - Edit your Harbor config so current-credential-name is set to a name that does not exist in the credentials list (or otherwise remove the named credential).
- Run the password change:
./harbor password --old-password oldpass --new-password newpass - Observe the process terminates with a fatal exit instead of returning a normal CLI error.
Expected Behavior
The password command should return a descriptive error if the current credential cannot be found and exit gracefully with a non-zero code (no abrupt process termination).
Helper functions (e.g., UpdateCredentialsInConfigFile, AddCredentialsToConfigFile) should return errors instead of calling log.Fatalf, allowing callers to handle/report failures.
Actual Behavior
UpdatePassword ignores the error from GetCredentials (existingCred, _ := utils.GetCredentials(...)) and builds a credential from zero-value fields.
UpdateCredentialsInConfigFile logs a fatal error (log.Fatalf("credential with name '%s' not found", ...)) and terminates the process immediately
Environment
- OS: Linux
- Go: go1.24.8 linux/amd64
- Tool version: local build from this repository (no release tag)
- Repo/branch: local workspace (include commit/branch when filing remotely)
Additional Context
This is triggered by stale or incorrect current-credential-name or by removing/mutating the named credential in the config.