{"record":{"id":"5eb549ed4267fd4c","repo":"litedb-org/LiteDB","slug":"connectionstring-5eb549","errorCode":null,"errorMessage":"connectionString","messagePattern":"connectionString","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"LiteDB/Client/Structures/ConnectionString.cs","lineNumber":70,"sourceCode":"        /// \"collation\": Set default collaction when database creation (default: \"[CurrentCulture]/IgnoreCase\")\n        /// </summary>\n        public Collation Collation { get; set; }\n\n        /// <summary>\n        /// Initialize empty connection string\n        /// </summary>\n        public ConnectionString()\n        {\n            _values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n        }\n\n        /// <summary>\n        /// Initialize connection string parsing string in \"key1=value1;key2=value2;....\" format or only \"filename\" as default (when no ; char found)\n        /// </summary>\n        public ConnectionString(string connectionString)\n            : this()\n        {\n            if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));\n\n            // create a dictionary from string name=value collection\n            if (connectionString.Contains(\"=\"))\n            {\n                _values.ParseKeyValue(connectionString);\n            }\n            else\n            {\n                _values[\"filename\"] = connectionString;\n            }\n\n            // setting values to properties\n            this.Connection = _values.GetValue(\"connection\", this.Connection);\n            this.Filename = _values.GetValue(\"filename\", this.Filename).Trim();\n\n            this.Password = _values.GetValue(\"password\", this.Password);\n\n            if(this.Password == string.Empty)","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Client/Structures/ConnectionString.cs#L52-L88","documentation":"ArgumentNullException thrown by the ConnectionString(string) constructor when the connectionString argument is null or an empty string. The constructor parses a key=value;key=value format or treats a bare string as a filename, so a null/empty input has nothing to parse.","triggerScenarios":"Calling new ConnectionString(null), new ConnectionString(\"\"), or passing a variable that resolved to null/empty (e.g., from configuration, command-line args, or environment variables that were not set).","commonSituations":"Reading the connection string from appsettings.json where the key is missing. Using environment variables that were not set in the deployment. Passing a null default when no configuration is available. Dependency injection resolving a null string into the constructor.","solutions":["Provide a valid filename or key=value pair string.","Read the connection string from configuration with a fallback default.","Validate the configuration value is non-empty before constructing."],"exampleFix":"// before\nvar cs = new ConnectionString(config[\"LiteDB:ConnectionString\"]); // may be null\n// after\nvar connStr = config[\"LiteDB:ConnectionString\"] ?? \"MyData.db\";\nvar cs = new ConnectionString(connStr);","handlingStrategy":"validation","validationCode":"var connStr = configuration ?? \"MyData.db\";\nif (string.IsNullOrEmpty(connStr))\n    throw new InvalidOperationException(\"Connection string is not configured.\");\nvar cs = new ConnectionString(connStr);","typeGuard":"static bool IsValidConnectionString(string s) => !string.IsNullOrEmpty(s);","tryCatchPattern":"try\n{\n    var cs = new ConnectionString(rawConnStr);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"connectionString\")\n{\n    rawConnStr = \"MyData.db\"; // fallback\n    var cs = new ConnectionString(rawConnStr);\n}","preventionTips":["Provide a default filename or connection string in configuration with a fallback.","Validate configuration values at application startup.","Use the parameterless constructor new ConnectionString() and set Filename manually if the source may be null."],"tags":["argument-null","connection-string","configuration","validation"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}