From 0523179468cbface531622b66d6c00d134758189 Mon Sep 17 00:00:00 2001 From: Pulkit Agrawal <97938993+pulkit-999@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:50:43 +0530 Subject: [PATCH] fix: prevent panic when home directory cannot be determined --- plugins/credentialhelper/store.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/credentialhelper/store.go b/plugins/credentialhelper/store.go index 357c7ded..fa421b99 100644 --- a/plugins/credentialhelper/store.go +++ b/plugins/credentialhelper/store.go @@ -141,10 +141,10 @@ var _ plugin.Plugin = &credentialHelperStore{} // https://github.com/docker/cli/blob/master/cli/config/config.go#L24 const envOverrideConfigDir = "DOCKER_CONFIG" -func getConfigPath() string { +func getConfigPath() (string,error) { configDir := os.Getenv(envOverrideConfigDir) if configDir != "" { - return configDir + return configDir,nil } // continue with normal config resolution @@ -156,6 +156,10 @@ func getConfigPath() string { } } + if home == "" { + return "", fmt.Errorf("cannot determine home directory") + } + // there might be a case here where a system does not report a home // directory based on the above steps taken from the CLI. // We will error when we try to open a non-exiting file.