{"record":{"id":"a39b4609106d69e3","repo":"microsoft/garnet","slug":"authentication-mode-authenticationmode-is-not-su","errorCode":null,"errorMessage":"Authentication mode {AuthenticationMode} is not supported.","messagePattern":"Authentication mode (.+?) is not supported\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"libs/host/Configuration/Options.cs","lineNumber":1030,"sourceCode":"\n        private IAuthenticationSettings GetAuthenticationSettings(ILogger logger = null)\n        {\n            switch (AuthenticationMode)\n            {\n                case GarnetAuthenticationMode.NoAuth:\n                    return new NoAuthSettings();\n                case GarnetAuthenticationMode.Password:\n                    return new PasswordAuthenticationSettings(Password);\n                case GarnetAuthenticationMode.Aad:\n                    return new AadAuthenticationSettings(AuthorizedAadApplicationIds?.Split(','), AadAudiences?.Split(','), AadIssuers?.Split(','), IssuerSigningTokenProvider.Create(AadAuthority, logger));\n                case GarnetAuthenticationMode.ACL:\n                    return new AclAuthenticationPasswordSettings(AclFile, Password);\n                case GarnetAuthenticationMode.AclWithAad:\n                    var aadAuthSettings = new AadAuthenticationSettings(AuthorizedAadApplicationIds?.Split(','), AadAudiences?.Split(','), AadIssuers?.Split(','), IssuerSigningTokenProvider.Create(AadAuthority, logger), AadValidateUsername.GetValueOrDefault());\n                    return new AclAuthenticationAadSettings(AclFile, Password, aadAuthSettings);\n                default:\n                    logger?.LogError(\"Unsupported authentication mode: {mode}\", AuthenticationMode);\n                    throw new Exception($\"Authentication mode {AuthenticationMode} is not supported.\");\n            }\n        }\n\n        public bool GetFastAofTruncate(ILogger logger = null)\n        {\n            if (MainMemoryReplication.GetValueOrDefault())\n            {\n                logger?.LogError(\"--main-memory-replication is deprecated. Use --fast-aof-truncate instead.\");\n                return true;\n            }\n            return FastAofTruncate.GetValueOrDefault();\n        }\n\n        /// <summary>\n        /// Creates a clone of the current Options object\n        /// This method creates a shallow copy of the values of properties decorated with the OptionAttribute\n        /// For IEnumerable types it creates a list containing a shallow copy of all the values in the original IEnumerable\n        /// </summary>","sourceCodeStart":1012,"sourceCodeEnd":1048,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/Options.cs#L1012-L1048","documentation":"Thrown by GetAuthenticationSettings when the AuthenticationMode enum value does not match any of the five known cases (NoAuth, Password, Aad, ACL, AclWithAad). This is a configuration validation error during server startup — Garnet refuses to boot with an authentication mode it cannot resolve. The value is typically corrupted by an invalid integer cast or a forward-incompatible enum value from a newer version.","triggerScenarios":"Calling Options.GetAuthenticationSettings with an AuthenticationMode value outside the defined GarnetAuthenticationMode enum range (e.g., (GarnetAuthenticationMode)99). Also triggered if a future enum member is added to GarnetAuthenticationMode without a corresponding case in the switch at Options.cs:1015.","commonSituations":"Loading a config file or JSON settings object where the AuthenticationMode field contains a raw integer that doesn't map to a valid enum member; deserializing a checkpoint from a newer Garnet version that added an auth mode unknown to the running binary; programmatically constructing Options and assigning an invalid cast.","solutions":["Check the AuthenticationMode value in your GarnetServerOptions / config file and ensure it is one of: NoAuth, Password, Aad, ACL, AclWithAad.","If loading config from an older/newer version, align the Garnet version of the config producer with the running server.","If constructing Options in code, validate AuthenticationMode with Enum.IsDefined before passing it to the server.","Inspect the preceding log line 'Unsupported authentication mode: {mode}' which prints the actual invalid value."],"exampleFix":"// before\nvar opts = new GarnetServerOptions { AuthenticationMode = (GarnetAuthenticationMode)99 };\n\n// after\nif (!Enum.IsDefined(typeof(GarnetAuthenticationMode), opts.AuthenticationMode))\n    throw new ArgumentOutOfRangeException(nameof(opts.AuthenticationMode), $\"Must be one of: {string.Join(\", \", Enum.GetNames<GarnetAuthenticationMode>())}\");","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(GarnetAuthenticationMode), opts.AuthenticationMode))\n    throw new ArgumentOutOfRangeException(\n        nameof(opts.AuthenticationMode),\n        $\"Invalid value {opts.AuthenticationMode}. Valid modes: {string.Join(\", \", Enum.GetNames<GarnetAuthenticationMode>())}\");","typeGuard":"static bool IsValidAuthMode(GarnetAuthenticationMode mode) =>\n    Enum.IsDefined(typeof(GarnetAuthenticationMode), mode);","tryCatchPattern":null,"preventionTips":["Validate enum values with Enum.IsDefined before assigning to AuthenticationMode.","Never cast arbitrary integers to GarnetAuthenticationMode without validation.","Keep config file producers and the Garnet server on the same version."],"tags":["authentication","configuration","startup","enum-validation"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}