{"record":{"id":"4c0c976009b9f30e","repo":"SignalR/SignalR","slug":"connectionstring-4c0c97","errorCode":null,"errorMessage":"connectionString","messagePattern":"connectionString","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AspNet.SignalR.StackExchangeRedis/RedisScaleoutConfiguration.cs","lineNumber":25,"sourceCode":"using StackExchange.Redis;\n\nnamespace Microsoft.AspNet.SignalR\n{\n    /// <summary>\n    /// Settings for the Redis scale-out message bus implementation.\n    /// </summary>\n    public class RedisScaleoutConfiguration : ScaleoutConfiguration\n    {\n        public RedisScaleoutConfiguration(string server, int port, string password, string eventKey)\n            : this(CreateConnectionString(server, port, password), eventKey)\n        {\n        }\n\n        public RedisScaleoutConfiguration(string connectionString, string eventKey)\n        {\n            if (connectionString == null)\n            {\n                throw new ArgumentNullException(\"connectionString\");\n            }\n\n            if (eventKey == null)\n            {\n                throw new ArgumentNullException(\"eventKey\");\n            }\n\n            ConnectionString = connectionString;\n            if (connectionString.Length > 0)\n            {\n                var options = ConfigurationOptions.Parse(connectionString);\n                Database = options.DefaultDatabase.GetValueOrDefault(0);\n            }\n            EventKey = eventKey;\n        }\n\n        /// <summary>\n        /// The connection string that needs to be passed to ConnectionMultiplexer","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/SignalR/SignalR/blob/693053b89a9e1f5ce819e3233ed159a6409de22b/src/Microsoft.AspNet.SignalR.StackExchangeRedis/RedisScaleoutConfiguration.cs#L7-L43","documentation":"ArgumentNullException guard in the StackExchangeRedis RedisScaleoutConfiguration constructor: connectionString must not be null. Note this checks only null (not empty) — an empty string is permitted and simply skips ConfigurationOptions parsing and Database detection.","triggerScenarios":"new RedisScaleoutConfiguration(null, eventKey) is constructed (or the server/port/password overload builds a null string), hitting the guard at RedisScaleoutConfiguration.cs:25.","commonSituations":"The connection string is sourced from a missing config key and is null; a variable that was never assigned is passed; the 4-argument overload is fed a null server. Note: CreateConnectionString formats with string.Format so a null server would not itself trigger this guard (it produces \"...password=...\") — the null check specifically catches a null connectionString argument to the 2-arg constructor.","solutions":["Provide a non-null connection string of the form 'host:port,password=...,abortConnect=false'.","If loading from config, verify the setting exists; treat missing as a startup error.","Prefer the (server, port, password, eventKey) overload which builds the string for you."],"exampleFix":"// before\nvar cs = ConfigurationManager.AppSettings[\"RedisConn\"];\nvar config = new RedisScaleoutConfiguration(cs, \"SignalR\"); // cs null -> throw\n\n// after\nvar config = new RedisScaleoutConfiguration(\"redis.example.com\", 6379, \"password\", \"SignalR\");\n// or guard:\nvar cs = ConfigurationManager.AppSettings[\"RedisConn\"] ?? throw new ConfigurationErrorsException(\"RedisConn missing\");\nvar config = new RedisScaleoutConfiguration(cs, \"SignalR\");","handlingStrategy":"validation","validationCode":"if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));\nvar config = new RedisScaleoutConfiguration(connectionString, eventKey);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the connection-string config value is non-null at startup.","Prefer the (server, port, password, eventKey) overload which builds the string.","Note: empty string is allowed (skips Database parsing) — only null throws."],"tags":["redis","argument-null","configuration","connection-string","validation","stackexchange-redis"],"backgroundTag":null,"analyzedSha":"693053b89a9e1f5ce819e3233ed159a6409de22b","analyzedAt":"2026-08-13T22:23:59.793Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}