{"record":{"id":"3b4a78138d2353ef","repo":"microsoft/garnet","slug":"no-configprovider-exists-for-file-type-filetype","errorCode":null,"errorMessage":"No ConfigProvider exists for file type: {fileType}.","messagePattern":"No ConfigProvider exists for file type: (.+?)\\.","errorType":"validation","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"libs/host/Configuration/ConfigProviders.cs","lineNumber":95,"sourceCode":"        /// Get a IConfigProvider instance based on its configuration file type\n        /// </summary>\n        /// <param name=\"fileType\">The configuration file type</param>\n        /// <param name=\"defaultOptions\">Options object containing default configuration values (used only when calling TrySerializeOptions with skipDefaultOptions)</param>\n        /// <returns></returns>\n        /// <exception cref=\"NotImplementedException\"></exception>\n        public static IConfigProvider GetConfigProvider(ConfigFileType fileType, Options defaultOptions = null)\n        {\n            IConfigProvider instance;\n            switch (fileType)\n            {\n                case ConfigFileType.GarnetConf:\n                    instance = GarnetConfigProvider.Instance;\n                    break;\n                case ConfigFileType.RedisConf:\n                    instance = RedisConfigProvider.Instance;\n                    break;\n                default:\n                    throw new NotImplementedException($\"No ConfigProvider exists for file type: {fileType}.\");\n            }\n\n            instance.DefaultOptions = defaultOptions;\n            return instance;\n        }\n    }\n\n    /// <summary>\n    /// Config provider for a garnet.conf file (JSON serialized Options object)\n    /// </summary>\n    internal class GarnetConfigProvider : IConfigProvider\n    {\n        private static readonly Lazy<IConfigProvider> LazyInstance;\n        private static Lazy<JsonSerializerOptions> LazyJsonSerializerOptions;\n        private static Lazy<JsonSerializerOptions> LazyJsonSerializerOptionsSkipDefaults;\n        private static Lazy<JsonReaderOptions> LazyJsonReaderOptions;\n\n        public static IConfigProvider Instance => LazyInstance.Value;","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/ConfigProviders.cs#L77-L113","documentation":"NotImplementedException thrown by ConfigProviders.GetConfigProvider when the ConfigFileType argument does not match any known case (GarnetConf or RedisConf). This is an exhaustive-switch guard: only garnet.conf and redis.conf file types are supported, and any other value (including future/new types or an invalid cast) hits the default branch.","triggerScenarios":"Calling GetConfigProvider with an undefined or invalid ConfigFileType enum value, or a value that was added to the enum but not yet handled in the switch. Also reachable via a bad config file extension that maps to an unsupported type.","commonSituations":"A new ConfigFileType enum member added without updating the switch; deserializing a config type from untrusted input that yields an out-of-range enum value; a version mismatch where the caller uses an enum member the loaded library does not recognize.","solutions":["Ensure the ConfigFileType passed is one of the supported values: ConfigFileType.GarnetConf or ConfigFileType.RedisConf.","If the enum was extended, update this library version to one that handles the new type.","Validate the config file extension/type before calling GetConfigProvider to give a clearer upstream error.","If loading from a path, confirm the file extension maps to a supported type."],"exampleFix":"// before\nvar provider = ConfigProviders.GetConfigProvider((ConfigFileType)999);\n\n// after\nvar provider = ConfigProviders.GetConfigProvider(ConfigFileType.GarnetConf);","handlingStrategy":"validation","validationCode":"bool IsValidConfigFileType(ConfigFileType t)\n    => t == ConfigFileType.GarnetConf || t == ConfigFileType.RedisConf;\n\nIConfigProvider GetProviderSafely(ConfigFileType type, Options defaults = null)\n{\n    if (!IsValidConfigFileType(type))\n        throw new ArgumentOutOfRangeException(nameof(type), $\"Unsupported config file type: {type}\");\n    return ConfigProviders.GetConfigProvider(type, defaults);\n}","typeGuard":"static bool IsSupportedConfigFileType(ConfigFileType t)\n    => Enum.IsDefined(t) && (t == ConfigFileType.GarnetConf || t == ConfigFileType.RedisConf);","tryCatchPattern":"try\n{\n    var provider = ConfigProviders.GetConfigProvider(fileType, defaults);\n}\ncatch (NotImplementedException ex) when (ex.Message.Contains(\"No ConfigProvider\"))\n{\n    logger.LogError(\"Unsupported config file type: {Type}\", fileType);\n    throw;\n}","preventionTips":["Validate the config file type enum against the two supported values before calling the factory.","Derive the ConfigFileType from the file extension using a controlled mapping, not free-form input."],"tags":["config","validation","enum","factory","notimplemented"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}