{"record":{"id":"455e3e173e1f41ce","repo":"git-ecosystem/git-credential-manager","slug":"invalid-protocol-request-argument-cannot-be-emp","errorCode":null,"errorMessage":"Invalid 'protocol' request argument (cannot be empty)","messagePattern":"Invalid 'protocol' request argument \\(cannot be empty\\)","errorType":"exception","errorClass":"Trace2InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Core/Commands/GitCommandBase.cs","lineNumber":65,"sourceCode":"            Context.Trace.WriteDictionarySecrets(inputDict, new []{ \"password\" }, StringComparer.OrdinalIgnoreCase);\n            IHostProvider provider = await _hostProviderRegistry.GetProviderAsync(request);\n            Context.Trace.WriteLine($\"Host provider '{provider.Name}' was selected.\");\n\n            await ExecuteInternalAsync(request, provider);\n\n            Context.Trace.WriteLine($\"End '{Name}' command...\");\n        }\n\n        protected virtual void EnsureMinimumRequest(GitRequest request)\n        {\n            if (request.Protocol is null)\n            {\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Missing 'protocol' request argument\");\n            }\n\n            if (string.IsNullOrWhiteSpace(request.Protocol))\n            {\n                throw new Trace2InvalidOperationException(Context.Trace2,\n                    \"Invalid 'protocol' request argument (cannot be empty)\");\n            }\n\n            if (request.Host is null)\n            {\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Missing 'host' request argument\");\n            }\n\n            if (string.IsNullOrWhiteSpace(request.Host))\n            {\n                throw new Trace2InvalidOperationException(Context.Trace2,\n                    \"Invalid 'host' request argument (cannot be empty)\");\n            }\n        }\n\n        /// <summary>\n        /// Execute the command using the given <see cref=\"GitRequest\"/> and <see cref=\"IHostProvider\"/>.\n        /// </summary>","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Commands/GitCommandBase.cs#L47-L83","documentation":"EnsureMinimumRequest rejects a 'protocol' argument that is present but empty or whitespace-only (string.IsNullOrWhiteSpace). Unlike error 50 (null), here the caller supplied protocol= with no value. The library requires a concrete scheme to build the credential target/URL.","triggerScenarios":"ExecuteAsync -> EnsureMinimumRequest where request.Protocol is non-null but null/whitespace, e.g. a literal `protocol=` line with an empty value in the credential input.","commonSituations":"Shell scripts that build the credential input with an unset variable (`protocol=$SCHEME` where SCHEME is empty); config generation that writes empty protocol keys; parsing bugs in wrapper tools that split on '=' and lose the value.","solutions":["Fix the input so `protocol=` carries a real scheme (https, http, ssh).","In shell wrappers, guard the variable: abort or default it if empty before composing the input.","If constructing a GitRequest in code, validate the scheme string is non-empty before calling.","Trace with GCM_TRACE=1 to confirm the exact input GCM received."],"exampleFix":"// before (shell wrapper)\nprintf 'protocol=%s\\nhost=%s\\n' \"$SCHEME\" \"$HOST\" | git-credential-manager store\n\n// after\n: \"${SCHEME:?SCHEME must not be empty}\"\nprintf 'protocol=%s\\nhost=%s\\n' \"$SCHEME\" \"$HOST\" | git-credential-manager store","handlingStrategy":"validation","validationCode":"if (request.Protocol != null && string.IsNullOrWhiteSpace(request.Protocol))\n    throw new ArgumentException(\"protocol must be a non-empty scheme like https\");","typeGuard":"bool HasNonEmptyProtocol(GitRequest r) => !string.IsNullOrWhiteSpace(r.Protocol);","tryCatchPattern":"try\n{\n    credentialHelper.Invoke(request);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"protocol\") && ex.Message.Contains(\"empty\"))\n{\n    // repair the empty protocol value and retry once\n}","preventionTips":["Never interpolate unset shell variables into credential input; use ${VAR:?} guards.","Trim and validate scheme strings at the boundary.","Add tests covering empty-value key=value inputs.","Inspect piped input with GCM_TRACE when debugging."],"tags":["git","credential-helper","empty-value","request-validation"],"backgroundTag":"empty-required-field","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"}