{"record":{"id":"872d2f504ec4223f","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-get-git-configuration-multi-valued-entri","errorCode":null,"errorMessage":"Failed to get Git configuration multi-valued entries with name regex '{nameRegex}'","messagePattern":"Failed to get Git configuration multi-valued entries with name regex '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":729,"sourceCode":"                gitArgs += $\" {QuoteCmdArg(valueRegex)}\";\n            }\n\n            using (ChildProcess git = _git.CreateProcess(gitArgs))\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                    case 1: // No results\n                        break;\n                    default:\n                        _trace.WriteLine($\"Failed to get all multivar regex '{nameRegex}' and value regex '{valueRegex}' (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, $\"Failed to get Git configuration multi-valued entries with name regex '{nameRegex}'\");\n                }\n\n                string[] entries = data.Split('\\0');\n                foreach (string entry in entries)\n                {\n                    string[] kvp = entry.Split(new[]{'\\n'}, count: 2);\n\n                    if (kvp.Length == 2)\n                    {\n                        yield return kvp[1];\n                    }\n                }\n            }\n        }\n\n        public void ReplaceAll(GitConfigurationLevel level, string name, string valueRegex, string value)\n        {\n            EnsureSpecificLevel(level);","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L711-L747","documentation":"Thrown when `git config --get-regexp` (multivar name/value regex query) exits with a code other than 0 or 1. Exit 1 (no matches) is tolerated; this error means git rejected the query — almost always an invalid regex or invalid key-name pattern — or the config itself is unreadable.","triggerScenarios":"Calling GetRegex(level, type, nameRegex, valueRegex) with a name or value regex that git/.NET-compiled-to-git treats as invalid, or when the underlying config cannot be parsed.","commonSituations":"Passing regexes with unbalanced parentheses or invalid escapes ('remote\\\\.origin\\\\' etc.); copying a .NET regex flavor git's POSIX regex engine does not support; querying a corrupted config.","solutions":["Test the exact regexes with `git config --get-regexp <nameRegex>` to see git's complaint","Fix the regex syntax (git uses POSIX basic/extended regex, not .NET flavor)","Escape dots in key names ('remote\\\\.origin') and validate parentheses/escapes","Wrap the call in try/catch and fall back to Enumerate + client-side filtering"],"exampleFix":"// before\nconfig.GetRegex(level, type, \"remote.*url\", \"(\"); // throws: invalid regex\n// after\nconfig.GetRegex(level, type, \"remote\\\\..*\\\\.url\", \"https://.*\"); // valid POSIX regex","handlingStrategy":"try-catch","validationCode":"static bool IsValidPosixRegex(string pattern) {\n    try { _ = new System.Text.RegularExpressions.Regex(pattern); return pattern.IndexOf('(') == pattern.LastIndexOf(')'); }\n    catch (ArgumentException) { return false; }\n}\n// also escape dots: name.Replace(\".\", \"\\\\.\")","typeGuard":null,"tryCatchPattern":"try { matches = cfg.GetRegex(level, type, nameRegex, valueRegex).ToList(); }\ncatch (GitException ex) { log.Warn($\"Regex query failed: {ex.Message}\"); matches = new List<string>(); }","preventionTips":["Use POSIX-compatible regex syntax, not .NET flavor constructs","Escape literal dots in key-name patterns","Verify patterns with `git config --get-regexp` before shipping","Fall back to Enumerate + in-memory filtering for complex matching"],"tags":["git","config","regex"],"backgroundTag":"invalid-regex-pattern","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"}