{"record":{"id":"c4a8910e9b9e5852","repo":"git-ecosystem/git-credential-manager","slug":"a-host-provider-cannot-be-registered-with-the-lega","errorCode":null,"errorMessage":"A host provider cannot be registered with the legacy authority ID '{AuthorityIdAuto}'","messagePattern":"A host provider cannot be registered with the legacy authority ID '(.+?)'","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Core/HostProviderRegistry.cs","lineNumber":77,"sourceCode":"\n            _context = context;\n            _hostProviders = new Dictionary<HostProviderPriority, ICollection<IHostProvider>>();\n        }\n\n        public void Register(IHostProvider hostProvider, HostProviderPriority priority)\n        {\n            EnsureArgument.NotNull(hostProvider, nameof(hostProvider));\n\n            if (StringComparer.OrdinalIgnoreCase.Equals(hostProvider.Id, Constants.ProviderIdAuto))\n            {\n                throw new ArgumentException(\n                    $\"A host provider cannot be registered with the ID '{Constants.ProviderIdAuto}'\",\n                    nameof(hostProvider));\n            }\n\n            if (hostProvider.SupportedAuthorityIds.Any(y => StringComparer.OrdinalIgnoreCase.Equals(y, Constants.AuthorityIdAuto)))\n            {\n                throw new ArgumentException(\n                    $\"A host provider cannot be registered with the legacy authority ID '{Constants.AuthorityIdAuto}'\",\n                    nameof(hostProvider));\n            }\n\n            if (!_hostProviders.TryGetValue(priority, out ICollection<IHostProvider> providers))\n            {\n                providers = new List<IHostProvider>();\n                _hostProviders[priority] = providers;\n            }\n\n            providers.Add(hostProvider);\n        }\n\n        public async Task<IHostProvider> GetProviderAsync(GitRequest request)\n        {\n            IHostProvider provider;\n\n            //","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/HostProviderRegistry.cs#L59-L95","documentation":"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.","triggerScenarios":"Registering an IHostProvider whose SupportedAuthorityIds collection contains \"auto\" (any casing).","commonSituations":"Custom providers migrated from older GCM versions that used 'auto' as a catch-all authority, or copy-pasted provider definitions listing generic authority IDs.","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"],"exampleFix":"// before\npublic override string[] SupportedAuthorityIds => new[] { Constants.AuthorityIdAuto };\n// after\npublic override string[] SupportedAuthorityIds => new[] { \"oauth\", \"basic\" };","handlingStrategy":"validation","validationCode":"if (provider.SupportedAuthorityIds.Any(a => string.Equals(a, \"auto\", StringComparison.OrdinalIgnoreCase)))\n    throw new ArgumentException(\"SupportedAuthorityIds must not contain the reserved value 'auto'\", nameof(provider));","typeGuard":"bool HasValidAuthorities(IHostProvider p) => p.SupportedAuthorityIds?.All(a => !a.Equals(\"auto\", StringComparison.OrdinalIgnoreCase)) == true;","tryCatchPattern":"try\n{\n    registry.Register(provider, HostProviderPriority.Normal);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"legacy authority ID\"))\n{\n    logger.LogError(ex, \"Remove 'auto' from SupportedAuthorityIds of {ProviderId}\", provider.Id);\n}","preventionTips":["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"],"tags":["host-provider","registration","reserved-identifier","authority"],"backgroundTag":"invalid-argument-value","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"}