git-ecosystem/git-credential-manager · error · Trace2InvalidOperationException
Missing 'protocol' request argument
Error message
Missing 'protocol' request argument
What it means
GitCommandBase.EnsureMinimumRequest validates that the incoming GitRequest carries the required 'protocol' field before executing any git command. The request.Protocol property was null, meaning the git invocation (or caller constructing the request) did not supply the protocol portion of the URL/scheme (e.g. https, http, ssh). This is thrown as a Trace2InvalidOperationException so the failure is recorded in the Trace2 diagnostics.
Solutions
- Ensure the git credential input includes a `protocol=<scheme>` line (e.g. protocol=https) before invoking GCM.
- If constructing a GitRequest in code, set request.Protocol explicitly to the URL scheme (https/http/ssh).
- Update/repair the Git installation so it passes standard credential key/value pairs to the helper.
- Check GCM tracing (GCM_TRACE) to see how the request was parsed if the input appears correct.
Example fix
// before (programmatic request missing protocol)
var request = new GitRequest { Host = "github.com" };
// after
var request = new GitRequest { Protocol = "https", Host = "github.com" }; Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(request.Protocol))
throw new ArgumentException("protocol must be provided, e.g. https"); Type guard
bool HasProtocol(GitRequest r) => !string.IsNullOrEmpty(r.Protocol);
Try / catch
try
{
await command.ExecuteAsync(input);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("'protocol'"))
{
// log and prompt for/repair the protocol argument
} Prevention
- Always emit protocol=, host= in credential helper inputs.
- Validate GitRequest fields before calling ExecuteAsync.
- Keep Git installations current so standard keys are passed.
- Enable GCM_TRACE during integration work.
When it happens
Trigger: ExecuteAsync calls EnsureMinimumRequest and the GitRequest.Protocol property is null — i.e. the protocol request argument was never set by the caller or by argument parsing of the git credential input.
Common situations: Invoking `git credential fill/store/erase` (or a GCM command) through a wrapper that strips or omits the protocol= line from the key=value input; custom automation that builds a GitRequest programmatically but forgets to set Protocol; unusual Git remotes or transports that do not pass a protocol.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Missing 'host' request argument
- Invalid 'protocol' request argument (cannot be empty)
- Invalid 'host' request argument (cannot be empty)
- Missing 'username' request argument
- Missing 'password' request argument
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/7afa4a1f144915be.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/Commands/GitCommandBase.cs:60
// Set the remote URI to scope settings to throughout the process from now on
Context.Settings.RemoteUri = request.GetRemoteUri();
// Determine the host provider
Context.Trace.WriteLine("Detecting host provider for request:");
Context.Trace.WriteDictionarySecrets(inputDict, new []{ "password" }, StringComparer.OrdinalIgnoreCase);
IHostProvider provider = await _hostProviderRegistry.GetProviderAsync(request);
Context.Trace.WriteLine($"Host provider '{provider.Name}' was selected.");
await ExecuteInternalAsync(request, provider);
Context.Trace.WriteLine($"End '{Name}' command...");
}
protected virtual void EnsureMinimumRequest(GitRequest request)
{
if (request.Protocol is null)
{
throw new Trace2InvalidOperationException(Context.Trace2, "Missing 'protocol' request argument");
}
if (string.IsNullOrWhiteSpace(request.Protocol))
{
throw new Trace2InvalidOperationException(Context.Trace2,
"Invalid 'protocol' request argument (cannot be empty)");
}
if (request.Host is null)
{
throw new Trace2InvalidOperationException(Context.Trace2, "Missing 'host' request argument");
}
if (string.IsNullOrWhiteSpace(request.Host))
{
throw new Trace2InvalidOperationException(Context.Trace2,
"Invalid 'host' request argument (cannot be empty)");
}View on GitHub (pinned to e8ce762cd0)