fix(config): report a local config file that cannot be parsed

What does this MR do and why?

A repository-local config file that exists but cannot be parsed is dropped silently, so glab runs on the global config while the user believes their per-repository overrides are applied.

parseConfig merges the local file only on success and has no else branch:

if localPath != "" {
	if _, localRoot, err := ParseConfigFile(localPath); err == nil {
		...merge...
	}
}

A parse error, a permission error and a missing file all end up treated the same.

The two neighbouring cases in the very same function already distinguish them. The main config at the top returns anything that is not os.IsNotExist, and the aliases file a few lines below ends with:

} else if !errors.Is(err, os.ErrNotExist) {
	return nil, err
}

This MR applies that same clause to the local file, so the fix matches the convention already in place rather than inventing one.

Test coverage

Two tests, because both halves matter:

  • Test_parseConfig_ReportsBrokenLocalConfig seeds local.yml with editor: [unclosed and expects an error.
  • Test_parseConfig_AllowsMissingLocalConfig points at a path that does not exist and expects success with the global value intact, so the change does not start rejecting the normal case of a repository without overrides.

Reverting only config_file.go:

--- FAIL: Test_parseConfig_ReportsBrokenLocalConfig

One thing worth flagging for the reviewer: go test ./internal/config/ is not clean on Windows, but it is not clean on main either. Test_ParseConfigFilePermissions, Test_checkForDuplicateConfigs_SymlinkSameFile, Test_BackupConfigFile and Test_WriteFile already fail there before this change, and they concern file permissions and symlinks. This MR does not touch them.

Closes #8425 (closed)

Merge request reports

Loading
Loading