{"record":{"id":"55a057a6560ac3b1","repo":"dotnet/orleans","slug":"connection-string-must-contain-characters","errorCode":null,"errorMessage":"Connection string must contain characters","messagePattern":"Connection string must contain characters","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/RelationalStorage.cs","lineNumber":103,"sourceCode":"        }\n\n\n        /// <summary>\n        /// Creates an instance of a database of type <see cref=\"IRelationalStorage\"/>.\n        /// </summary>\n        /// <param name=\"invariantName\">The invariant name of the connector for this database.</param>\n        /// <param name=\"connectionString\">The connection string this database should use for database operations.</param>\n        /// <returns></returns>\n        public static IRelationalStorage CreateInstance(string invariantName, string connectionString)\n        {\n            if (string.IsNullOrWhiteSpace(invariantName))\n            {\n                throw new ArgumentException(\"The name of invariant must contain characters\", nameof(invariantName));\n            }\n\n            if (string.IsNullOrWhiteSpace(connectionString))\n            {\n                throw new ArgumentException(\"Connection string must contain characters\", nameof(connectionString));\n            }\n\n            return new RelationalStorage(invariantName, connectionString);\n        }\n\n        /// <summary>\n        /// Creates an instance of a database of type <see cref=\"IRelationalStorage\"/>.\n        /// </summary>\n        /// <param name=\"invariantName\">The invariant name of the connector for this database.</param>\n        /// <param name=\"dataSource\">The data source used to open database connections.</param>\n        /// <returns>A relational storage instance.</returns>\n        public static IRelationalStorage CreateInstance(string invariantName, DbDataSource dataSource)\n        {\n            if (string.IsNullOrWhiteSpace(invariantName))\n            {\n                throw new ArgumentException(\"The name of invariant must contain characters\", nameof(invariantName));\n            }\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/RelationalStorage.cs#L85-L121","documentation":"Thrown by RelationalStorage.CreateInstance(string invariantName, string connectionString) when connectionString is null, empty, or whitespace. The connection string is required to open connections via DbConnectionFactory; a blank value cannot reach any database. ArgumentException names 'connectionString'.","triggerScenarios":"Calling CreateInstance with a populated invariant but a missing/blank connection string. Typical when the connection string key is misspelled in config or the secrets provider returned empty.","commonSituations":"Connection string not injected from Azure Key Vault / environment variables in production; wrong config key name (e.g. 'ConnectionString' vs 'connectionString'); empty value left during local-to-prod migration; user-secrets not loaded in Development.","solutions":["Provide a valid ADO.NET connection string, e.g. 'Server=...;Database=...;User Id=...;Password=...'.","Bind connection string from IConfiguration / options and verify it is non-empty at startup before constructing storage.","Resolve the connection string from your secrets manager (Key Vault, user-secrets) and log its presence (not its value) for diagnostics.","If using DbDataSource instead, switch to the CreateInstance(invariantName, dataSource) overload."],"exampleFix":"// before\nvar storage = RelationalStorage.CreateInstance(\"System.Data.SqlClient\", \"  \");\n\n// after\nvar cs = config.GetConnectionString(\"OrleansStorage\")\n    ?? throw new InvalidOperationException(\"OrleansStorage connection string missing.\");\nvar storage = RelationalStorage.CreateInstance(\"System.Data.SqlClient\", cs);","handlingStrategy":"validation","validationCode":"var cs = config.GetConnectionString(\"OrleansStorage\")\n    ?? throw new InvalidOperationException(\"Connection string 'OrleansStorage' missing.\");\nif (string.IsNullOrWhiteSpace(cs)) throw new InvalidOperationException(\"Empty connection string.\");","typeGuard":"static bool HasConnectionString(string? s) => !string.IsNullOrWhiteSpace(s);","tryCatchPattern":"try { storage = RelationalStorage.CreateInstance(inv, cs); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(cs)) { /* load secret */ }","preventionTips":["Pull connection strings from a secrets manager and assert non-empty.","Log connection-string presence (not value) at startup.","Use separate config keys per storage provider to avoid clobbering."],"tags":["csharp","dotnet","orleans","adonet","configuration","connection-string","argument-validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}