{"record":{"id":"32634aaf660a1dcd","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-enumerate-all-git-configuration-entries","errorCode":null,"errorMessage":"Failed to enumerate all Git configuration entries","messagePattern":"Failed to enumerate all Git configuration entries","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":480,"sourceCode":"            }\n\n            // Fall back to original implementation\n            string levelArg = GetLevelFilterArg(level);\n            using (ChildProcess git = _git.CreateProcess($\"config --null {levelArg} --list\"))\n            {\n                git.Start(Trace2ProcessClass.Git);\n                // To avoid deadlocks, always read the output stream first and then wait\n                // TODO: don't read in all the data at once; stream it\n                string data = git.StandardOutput.ReadToEnd();\n                git.WaitForExit();\n\n                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                        break;\n                    default:\n                        _trace.WriteLine($\"Failed to enumerate config entries (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, \"Failed to enumerate all Git configuration entries\");\n                }\n\n                var name  = new StringBuilder();\n                var value = new StringBuilder();\n                int i = 0;\n                while (i < data.Length)\n                {\n                    name.Clear();\n                    value.Clear();\n\n                    // Read key name (LF terminated)\n                    while (i < data.Length && data[i] != '\\n')\n                    {\n                        name.Append(data[i++]);\n                    }\n\n                    if (i >= data.Length)\n                    {","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L462-L498","documentation":"Thrown by GitConfiguration.Enumerate when `git config --list` (at a given level) exits non-zero. This error means the requested configuration could not be read at all — typically a malformed config file or an inaccessible config location — so the library cannot return any entries.","triggerScenarios":"Calling Enumerate(level) when the underlying `git config --list --<level>` process fails: malformed .gitconfig syntax, unreadable system/global config file, or invalid level combination.","commonSituations":"Hand-edited .gitconfig with syntax errors; XDG_CONFIG_HOME or HOME pointing somewhere unreadable; corporate config templates with duplicate/conflicting entries.","solutions":["Run `git config --list` manually to find the parse error message and offending file","Fix the malformed line in the indicated config file (git prints file:line)","Back up and regenerate the broken config file if it is beyond repair","Check HOME/XDG_CONFIG_HOME and file permissions for the global/system config"],"exampleFix":"// before\nvar entries = config.Enumerate(GitConfigurationLevel.Local); // throws on malformed file\n// after\nList<string> entries;\ntry { entries = config.Enumerate(GitConfigurationLevel.Local).ToList(); }\ncatch (GitException ex) { entries = new List<string>(); Log(ex.Message); }","handlingStrategy":"try-catch","validationCode":"var probe = Process.Run(\"git\", \"config --list\", workingDir);\nif (probe.ExitCode != 0) { /* fix config before calling Enumerate */ }","typeGuard":"bool CanReadConfig(GitConfiguration cfg) { try { _ = cfg.Enumerate(GitConfigurationLevel.Local).Any(); return true; } catch (GitException) { return false; } }","tryCatchPattern":"try { entries = cfg.Enumerate(level).ToList(); }\ncatch (GitException ex) { log.Error($\"Config unreadable: {ex.Message}\"); entries = new List<string>(); }","preventionTips":["Lint .gitconfig files after manual edits (git prints file:line for parse errors)","Do not template configs with duplicate conflicting keys","Verify HOME/XDG_CONFIG_HOME are set and readable in services/CI","Back up configs before bulk edits"],"tags":["git","config","process"],"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-16T09:17:16.951Z"}