{"record":{"id":"3dcf26125b314451","repo":"git-ecosystem/git-credential-manager","slug":"invalid-host-request-argument-cannot-be-empty","errorCode":null,"errorMessage":"Invalid 'host' request argument (cannot be empty)","messagePattern":"Invalid 'host' request argument \\(cannot be empty\\)","errorType":"exception","errorClass":"Trace2InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Core/Commands/GitCommandBase.cs","lineNumber":76,"sourceCode":"            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>\n        /// <param name=\"request\">Input arguments of the current Git credential query.</param>\n        /// <param name=\"provider\">Host provider for the current <see cref=\"GitRequest\"/>.</param>\n        /// <returns>Awaitable task for the command execution.</returns>\n        protected abstract Task ExecuteInternalAsync(GitRequest request, IHostProvider provider);\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":90,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Commands/GitCommandBase.cs#L58-L90","documentation":"EnsureMinimumRequest rejects a 'host' argument that is present but empty or whitespace-only (string.IsNullOrWhiteSpace). The caller supplied `host=` with no value, which cannot identify a credential target.","triggerScenarios":"ExecuteAsync -> EnsureMinimumRequest where request.Host is non-null but whitespace, e.g. an input line `host=` with an empty value.","commonSituations":"Scripts interpolating an empty HOST variable; tools that extract the host from a malformed remote URL and produce an empty string; templated CI configs where a host placeholder was never filled.","solutions":["Provide a real hostname on the `host=` line of the credential input.","In wrappers, fail fast on an empty host variable before composing input.","Validate GitRequest.Host with string.IsNullOrWhiteSpace before invoking the command in code.","Check the remote URL (`git remote -v`) is complete and includes a hostname."],"exampleFix":"// before (shell wrapper)\nprintf 'protocol=https\\nhost=%s\\n' \"$HOST\" | git-credential-manager store\n\n// after\n: \"${HOST:?HOST must not be empty}\"\nprintf 'protocol=https\\nhost=%s\\n' \"$HOST\" | git-credential-manager store","handlingStrategy":"validation","validationCode":"if (request.Host != null && string.IsNullOrWhiteSpace(request.Host))\n    throw new ArgumentException(\"host must be a non-empty hostname\");","typeGuard":"bool HasNonEmptyHost(GitRequest r) => !string.IsNullOrWhiteSpace(r.Host);","tryCatchPattern":"try\n{\n    credentialHelper.Invoke(request);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"host\") && ex.Message.Contains(\"empty\"))\n{\n    // fix the empty host value, then retry\n}","preventionTips":["Fail fast on empty host variables in scripts (${HOST:?}).","Parse host from the remote URL with a checked URL parser.","Fill CI/host placeholders via mandatory template validation.","Log the exact key=value input sent to GCM."],"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"}