{"record":{"id":"208cc866b2143885","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-get-all-git-configuration-entries-name","errorCode":null,"errorMessage":"Failed to get all Git configuration entries '{name}'","messagePattern":"Failed to get all Git configuration entries '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":698,"sourceCode":"                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                        string[] entries = data.Split('\\0');\n\n                        // Because each line terminates with the \\0 character, splitting leaves us with one\n                        // bogus blank entry at the end of the array which we should ignore\n                        for (var i = 0; i < entries.Length - 1; i++)\n                        {\n                            yield return entries[i];\n                        }\n                        break;\n\n                    case 1: // No results\n                        break;\n\n                    default:\n                        _trace.WriteLine($\"Failed to get all config entries '{name}' (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, $\"Failed to get all Git configuration entries '{name}'\");\n                }\n            }\n        }\n\n        public IEnumerable<string> GetRegex(GitConfigurationLevel level, GitConfigurationType type, string nameRegex, string valueRegex)\n        {\n            string levelArg = GetLevelFilterArg(level);\n            string typeArg = GetCanonicalizeTypeArg(type);\n\n            var gitArgs = $\"config --null {levelArg} {typeArg} --get-regex {QuoteCmdArg(nameRegex)}\";\n            if (valueRegex != null)\n            {\n                gitArgs += $\" {QuoteCmdArg(valueRegex)}\";\n            }\n\n            using (ChildProcess git = _git.CreateProcess(gitArgs))\n            {\n                git.Start(Trace2ProcessClass.Git);","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L680-L716","documentation":"Thrown by GitConfiguration.GetAll when `git config --get-all <name>` exits with a code other than 0 or 1. Exit 1 means no results and is tolerated; any other exit code (2+) indicates a real failure such as a malformed key or an unreadable config.","triggerScenarios":"Calling GetAll(level, type, name) with a syntactically invalid key name, or when the config file is corrupted/unreadable so git cannot even evaluate the query.","commonSituations":"Querying a key like 'http' (no subkey) which git rejects; querying after a broken editor or merge tool corrupted .gitconfig; environment where HOME is unset so system config resolution fails oddly.","solutions":["Validate the key format: must be 'section.key' or 'section.subsection.key' with a final subkey","Test with `git config --get-all <name>` manually to capture git's stderr","Repair the corrupted config file git points to in its error message","Handle the empty case separately — exit 1 (no entries) does not throw"],"exampleFix":"// before\nvar vals = config.GetAll(level, GitConfigurationType.Path, \"remote\"); // throws: key lacks subkey\n// after\nvar vals = config.GetAll(level, GitConfigurationType.Path, \"remote.origin.url\");","handlingStrategy":"validation","validationCode":"static bool IsValidConfigKey(string name) {\n    var parts = name.Split('.');\n    return parts.Length >= 2 && parts.All(p => p.Length > 0);\n}\n// GetAll tolerates 'no results'; validate key format before querying","typeGuard":null,"tryCatchPattern":"try { values = cfg.GetAll(level, type, name).ToList(); }\ncatch (GitException ex) { log.Warn($\"GetAll '{name}' failed: {ex.Message}\"); values = new List<string>(); }","preventionTips":["Never query a section name alone; always include the final subkey","Distinguish 'no results' (exit 1, tolerated) from real failures (exit 2+)","Repair corrupted configs promptly — any config read can then fail","Escape dots when building key names programmatically"],"tags":["git","config","query"],"backgroundTag":"git-command-failed","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}