microsoft/garnet · error · NotImplementedException

No ConfigProvider exists for file type: {fileType}.

Error message

No ConfigProvider exists for file type: {fileType}.

What it means

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.

Source

Thrown at libs/host/Configuration/ConfigProviders.cs:95

        /// Get a IConfigProvider instance based on its configuration file type
        /// </summary>
        /// <param name="fileType">The configuration file type</param>
        /// <param name="defaultOptions">Options object containing default configuration values (used only when calling TrySerializeOptions with skipDefaultOptions)</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public static IConfigProvider GetConfigProvider(ConfigFileType fileType, Options defaultOptions = null)
        {
            IConfigProvider instance;
            switch (fileType)
            {
                case ConfigFileType.GarnetConf:
                    instance = GarnetConfigProvider.Instance;
                    break;
                case ConfigFileType.RedisConf:
                    instance = RedisConfigProvider.Instance;
                    break;
                default:
                    throw new NotImplementedException($"No ConfigProvider exists for file type: {fileType}.");
            }

            instance.DefaultOptions = defaultOptions;
            return instance;
        }
    }

    /// <summary>
    /// Config provider for a garnet.conf file (JSON serialized Options object)
    /// </summary>
    internal class GarnetConfigProvider : IConfigProvider
    {
        private static readonly Lazy<IConfigProvider> LazyInstance;
        private static Lazy<JsonSerializerOptions> LazyJsonSerializerOptions;
        private static Lazy<JsonSerializerOptions> LazyJsonSerializerOptionsSkipDefaults;
        private static Lazy<JsonReaderOptions> LazyJsonReaderOptions;

        public static IConfigProvider Instance => LazyInstance.Value;

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Ensure the ConfigFileType passed is one of the supported values: ConfigFileType.GarnetConf or ConfigFileType.RedisConf.
  2. If the enum was extended, update this library version to one that handles the new type.
  3. Validate the config file extension/type before calling GetConfigProvider to give a clearer upstream error.
  4. If loading from a path, confirm the file extension maps to a supported type.

Example fix

// before
var provider = ConfigProviders.GetConfigProvider((ConfigFileType)999);

// after
var provider = ConfigProviders.GetConfigProvider(ConfigFileType.GarnetConf);
Defensive patterns

Strategy: validation

Validate before calling

bool IsValidConfigFileType(ConfigFileType t)
    => t == ConfigFileType.GarnetConf || t == ConfigFileType.RedisConf;

IConfigProvider GetProviderSafely(ConfigFileType type, Options defaults = null)
{
    if (!IsValidConfigFileType(type))
        throw new ArgumentOutOfRangeException(nameof(type), $"Unsupported config file type: {type}");
    return ConfigProviders.GetConfigProvider(type, defaults);
}

Type guard

static bool IsSupportedConfigFileType(ConfigFileType t)
    => Enum.IsDefined(t) && (t == ConfigFileType.GarnetConf || t == ConfigFileType.RedisConf);

Try / catch

try
{
    var provider = ConfigProviders.GetConfigProvider(fileType, defaults);
}
catch (NotImplementedException ex) when (ex.Message.Contains("No ConfigProvider"))
{
    logger.LogError("Unsupported config file type: {Type}", fileType);
    throw;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13). Data as JSON: /api/errors/3b4a78138d2353ef. Report an issue: GitHub.