diff --git a/cli/config/config.go b/cli/config/config.go index 5a51843260..910b3c0064 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -143,7 +143,7 @@ func load(configDir string) (*configfile.ConfigFile, error) { defer file.Close() err = configFile.LoadFromReader(file) if err != nil { - err = errors.Wrapf(err, "loading config file: %s: ", filename) + err = errors.Wrapf(err, "parsing config file (%s)", filename) } return configFile, err } diff --git a/cli/config/config_test.go b/cli/config/config_test.go index e74a25863e..9e8c89238e 100644 --- a/cli/config/config_test.go +++ b/cli/config/config_test.go @@ -118,6 +118,17 @@ func TestEmptyJSON(t *testing.T) { saveConfigAndValidateNewFormat(t, config, tmpHome) } +func TestMalformedJSON(t *testing.T) { + tmpHome := t.TempDir() + + fn := filepath.Join(tmpHome, ConfigFileName) + err := os.WriteFile(fn, []byte("{"), 0o600) + assert.NilError(t, err) + + _, err = Load(tmpHome) + assert.Check(t, is.ErrorContains(err, fmt.Sprintf(`parsing config file (%s):`, fn))) +} + func TestNewJSON(t *testing.T) { tmpHome := t.TempDir()