git-ecosystem/git-credential-manager · error · ArgumentException
A host provider cannot be registered with the legacy…
Error message
A host provider cannot be registered with the legacy authority ID '{AuthorityIdAuto}' What it means
HostProviderRegistry.Register also rejects providers that declare the legacy authority ID 'auto' (Constants.AuthorityIdAuto) in SupportedAuthorityIds, because 'auto' is reserved for automatic authority detection. Any provider advertising it is refused with an ArgumentException so auto-detection semantics stay unambiguous.
Solutions
- Remove 'auto' from SupportedAuthorityIds and list concrete authority IDs the provider supports (e.g. "oauth", "basic")
- Audit custom provider implementations for legacy 'auto' authority declarations from older versions
- If the provider should handle unknown authorities, implement explicit authority IDs instead of relying on the reserved value
Example fix
// before
public override string[] SupportedAuthorityIds => new[] { Constants.AuthorityIdAuto };
// after
public override string[] SupportedAuthorityIds => new[] { "oauth", "basic" }; Defensive patterns
Strategy: validation
Validate before calling
if (provider.SupportedAuthorityIds.Any(a => string.Equals(a, "auto", StringComparison.OrdinalIgnoreCase)))
throw new ArgumentException("SupportedAuthorityIds must not contain the reserved value 'auto'", nameof(provider)); Type guard
bool HasValidAuthorities(IHostProvider p) => p.SupportedAuthorityIds?.All(a => !a.Equals("auto", StringComparison.OrdinalIgnoreCase)) == true; Try / catch
try
{
registry.Register(provider, HostProviderPriority.Normal);
}
catch (ArgumentException ex) when (ex.Message.Contains("legacy authority ID"))
{
logger.LogError(ex, "Remove 'auto' from SupportedAuthorityIds of {ProviderId}", provider.Id);
} Prevention
- List concrete authority IDs only; treat 'auto' as reserved by the registry
- Audit providers ported from older GCM versions for legacy 'auto' authority entries
- Cover provider registration with a unit test that registers every provider at startup
When it happens
Trigger: Registering an IHostProvider whose SupportedAuthorityIds collection contains "auto" (any casing).
Common situations: Custom providers migrated from older GCM versions that used 'auto' as a catch-all authority, or copy-pasted provider definitions listing generic authority IDs.
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 ID
- Unable to detect host provider without a remote URL
- No host provider available to service this request.
- Host is not Azure DevOps.
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/c4a8910e9b9e5852.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/HostProviderRegistry.cs:77
_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);
}
public async Task<IHostProvider> GetProviderAsync(GitRequest request)
{
IHostProvider provider;
//View on GitHub (pinned to e8ce762cd0)