{"record":{"id":"314ff783c1e15e18","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-set-git-configuration-entry-name","errorCode":null,"errorMessage":"Failed to set Git configuration entry '{name}'","messagePattern":"Failed to set Git configuration entry '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GitConfiguration.cs","lineNumber":598,"sourceCode":"\n        public void Set(GitConfigurationLevel level, string name, string value)\n        {\n            EnsureSpecificLevel(level);\n\n            string levelArg = GetLevelFilterArg(level);\n            using (ChildProcess git = _git.CreateProcess($\"config {levelArg} {QuoteCmdArg(name)} {QuoteCmdArg(value)}\"))\n            {\n                git.Start(Trace2ProcessClass.Git);\n                git.WaitForExit();\n\n                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                        InvalidateCache();\n                        break;\n                    default:\n                        _trace.WriteLine($\"Failed to set config entry '{name}' to value '{value}' (exit={git.ExitCode}, level={level})\");\n                        throw GitProcess.CreateGitException(git, $\"Failed to set Git configuration entry '{name}'\");\n                }\n            }\n        }\n\n        public void Add(GitConfigurationLevel level, string name, string value)\n        {\n            EnsureSpecificLevel(level);\n\n            string levelArg = GetLevelFilterArg(level);\n            using (ChildProcess git = _git.CreateProcess($\"config {levelArg} --add {QuoteCmdArg(name)} {QuoteCmdArg(value)}\"))\n            {\n                git.Start(Trace2ProcessClass.Git);\n                git.WaitForExit();\n\n                switch (git.ExitCode)\n                {\n                    case 0: // OK\n                        InvalidateCache();","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitConfiguration.cs#L580-L616","documentation":"Thrown by GitConfiguration.Set when `git config <name> <value>` exits non-zero. The trace line includes the exit code and level. Common causes are an invalid section/key name or a locked/unwritable config file.","triggerScenarios":"Calling Set(level, name, value) where the key name is malformed (e.g. missing section orsubsection dot), the target config file is read-only, or git rejects the write (invalid key, unwritable location).","commonSituations":"Passing 'httpSslVerify' without a section instead of 'http.sslVerify'; writing to a repo whose .git/config is read-only or owned by another user; trying to set in a level whose file cannot be created.","solutions":["Verify the key uses valid 'section.subsection.key' format (run `git config --get <name>` first)","Check the target config file is writable (permissions, read-only attribute, file lock)","Run the equivalent `git config <level> <name> <value>` manually to see git's error","Confirm the repository/level location exists before writing"],"exampleFix":"// before\nconfig.Set(GitConfigurationLevel.Local, \"httpSslVerify\", \"false\"); // throws: invalid key\n// after\nconfig.Set(GitConfigurationLevel.Local, \"http.sslVerify\", \"false\"); // valid section.key","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// call only if IsValidConfigKey(name)","typeGuard":null,"tryCatchPattern":"try { cfg.Set(level, name, value); }\ncatch (GitException ex) { log.Error($\"Set '{name}' failed: {ex.Message}\"); }","preventionTips":["Always use fully qualified section.key names (e.g. http.sslVerify, not sslVerify)","Check target config file writability before writing","Prefer the library API over editing config files directly","Test the key with `git config --get <name>` first"],"tags":["git","config","write"],"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"}