{"record":{"id":"75e2300a5aa8380f","repo":"git-ecosystem/git-credential-manager","slug":"cannot-render-the-none-capability-to-a-protocol-na","errorCode":null,"errorMessage":"Cannot render the None capability to a protocol name.","messagePattern":"Cannot render the None capability to a protocol name\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Core/GitCapabilities.cs","lineNumber":93,"sourceCode":"    /// Render a single <see cref=\"GitCapabilities\"/> flag to its on-the-wire\n    /// protocol name (e.g. <c>\"authtype\"</c>).\n    /// </summary>\n    /// <remarks>\n    /// The protocol name is always lowercase. New entries must be added here\n    /// in lockstep with new <see cref=\"GitCapabilities\"/> flag values to avoid\n    /// emitting an incorrect name to Git.\n    /// </remarks>\n    public static string ToProtocolName(GitCapabilities capability)\n    {\n        // Add each flag's protocol name here as the capability is wired up.\n        // The default lowercase enum name is intentionally NOT used because\n        // some protocol names will not be a single token (e.g. authtype is fine\n        // but a hypothetical \"PasswordExpiryUtc\" would have to map to a\n        // protocol name distinct from its .NET enum name).\n        return capability switch\n        {\n            GitCapabilities.State => \"state\",\n            GitCapabilities.None => throw new ArgumentException(\n                \"Cannot render the None capability to a protocol name.\",\n                nameof(capability)),\n            _ => throw new ArgumentOutOfRangeException(\n                nameof(capability),\n                capability,\n                \"No protocol name mapping is defined for the given capability.\"),\n        };\n    }\n\n    /// <summary>\n    /// Enumerate each individual <see cref=\"GitCapabilities\"/> flag set in\n    /// <paramref name=\"capabilities\"/>, rendered to its on-the-wire protocol name.\n    /// </summary>\n    /// <remarks>\n    /// Returns an empty sequence for <see cref=\"GitCapabilities.None\"/>. Each\n    /// emitted name comes from <see cref=\"ToProtocolName\"/>.\n    /// </remarks>\n    public static IEnumerable<string> ToProtocolNames(GitCapabilities capabilities)","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GitCapabilities.cs#L75-L111","documentation":"GitCapabilities.ToProtocolName maps a GitCapabilities.State enum value to the wire protocol capability name string. The None sentinel does not represent a real capability, so it can never be rendered; calling ToProtocolName with it throws ArgumentException naming the parameter. ToProtocolNames callers should filter None out before mapping.","triggerScenarios":"Calling ToProtocolName(GitCapabilities.None) directly, or via ToProtocolNames when a capabilities set includes the None flag without being filtered, e.g. building protocol capability strings from a default/unset capabilities enum.","commonSituations":"Code that initializes a capabilities variable to GitCapabilities.None and forgets to add real capabilities before serializing to the Git protocol; custom integrations constructing capability lists programmatically.","solutions":["Filter out GitCapabilities.None before calling ToProtocolNames/ToProtocolName.","Ensure the capabilities value is populated with actual capabilities (e.g. State) before serialization.","Guard with an explicit check and skip rendering when capability == GitCapabilities.None."],"exampleFix":"// before\nvar names = capabilities.ToProtocolNames(); // includes None\n// after\nif (capabilities.HasFlag(GitCapabilities.None))\n    capabilities &= ~GitCapabilities.None;\nvar names = capabilities.ToProtocolNames();","handlingStrategy":"validation","validationCode":"if (capabilities.HasFlag(GitCapabilities.None))\n    capabilities &= ~GitCapabilities.None;\nvar protocolNames = capabilities.ToProtocolNames();","typeGuard":"bool IsRenderableCapability(GitCapabilities.State c) => c != GitCapabilities.None;","tryCatchPattern":"try\n{\n    var name = capability.ToProtocolName();\n}\ncatch (ArgumentException)\n{\n    // capability was None; skip rendering it\n}","preventionTips":["Never initialize capability sets to None and then serialize them directly.","Strip the None sentinel before any wire-protocol serialization.","Use explicit capability constants rather than default enum values."],"tags":["git-protocol","capabilities","argument-validation"],"backgroundTag":"invalid-argument-value","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"}