git-ecosystem/git-credential-manager · error · ArgumentException
A host provider cannot be registered with the ID
Error message
A host provider cannot be registered with the ID '{ProviderIdAuto}' What it means
HostProviderRegistry.Register rejects any IHostProvider whose Id equals the reserved value 'auto' (Constants.ProviderIdAuto, compared OrdinalIgnoreCase). 'auto' is reserved for the automatic host-detection provider, so a custom provider claiming that ID would conflict with built-in detection. The library throws ArgumentException naming the offending parameter.
Solutions
- Set the provider's Id property to a unique, non-'auto' constant (e.g. "mycompany")
- Check provider.Id before registering and fail fast with a clear message
- If the provider is meant to be chosen automatically, do not register it manually — rely on detection via SupportedAuthorityIds
Example fix
// before
var provider = new MyHostProvider { Id = Constants.ProviderIdAuto };
registry.Register(provider, HostProviderPriority.Normal); // throws
// after
var provider = new MyHostProvider { Id = "mycompany" };
registry.Register(provider, HostProviderPriority.Normal); Defensive patterns
Strategy: validation
Validate before calling
if (string.Equals(provider.Id, "auto", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("Provider Id must not be the reserved value 'auto'", nameof(provider)); Type guard
bool HasValidProviderId(IHostProvider p) => !string.IsNullOrWhiteSpace(p.Id) && !p.Id.Equals("auto", StringComparison.OrdinalIgnoreCase); Try / catch
try
{
registry.Register(provider, HostProviderPriority.Normal);
}
catch (ArgumentException ex)
{
logger.LogError(ex, "Provider registration rejected: {Message}", ex.Message);
} Prevention
- Always assign a unique, non-reserved Id constant to custom host providers
- Add an assertion/unit test that provider.Id != Constants.ProviderIdAuto before registration
- Never use built-in Constants.ProviderIdAuto/AuthorityIdAuto values for your own providers
When it happens
Trigger: Calling hostProviderRegistry.Register(provider, priority) where provider.Id == "auto" (any casing).
Common situations: Writing a custom host provider and forgetting to set a unique Id, copying sample code that leaves the default/placeholder ID 'auto', or programmatic provider injection in tests.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- A host provider cannot be registered with the legacy…
- Must specify at least one AuthenticationModes
- Argument cannot be empty or white space.
- Argument must be an absolute URI.
- Argument must be positive or zero (non-negative).
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/4081507b4b19c809.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/HostProviderRegistry.cs:70
{
private readonly ICommandContext _context;
private readonly IDictionary<HostProviderPriority, ICollection<IHostProvider>> _hostProviders;
public HostProviderRegistry(ICommandContext context)
{
EnsureArgument.NotNull(context, nameof(context));
_context = context;
_hostProviders = new Dictionary<HostProviderPriority, ICollection<IHostProvider>>();
}
public void Register(IHostProvider hostProvider, HostProviderPriority priority)
{
EnsureArgument.NotNull(hostProvider, nameof(hostProvider));
if (StringComparer.OrdinalIgnoreCase.Equals(hostProvider.Id, Constants.ProviderIdAuto))
{
throw new ArgumentException(
$"A host provider cannot be registered with the ID '{Constants.ProviderIdAuto}'",
nameof(hostProvider));
}
if (hostProvider.SupportedAuthorityIds.Any(y => StringComparer.OrdinalIgnoreCase.Equals(y, Constants.AuthorityIdAuto)))
{
throw new ArgumentException(
$"A host provider cannot be registered with the legacy authority ID '{Constants.AuthorityIdAuto}'",
nameof(hostProvider));
}
if (!_hostProviders.TryGetValue(priority, out ICollection<IHostProvider> providers))
{
providers = new List<IHostProvider>();
_hostProviders[priority] = providers;
}
providers.Add(hostProvider);View on GitHub (pinned to e8ce762cd0)