{"record":{"id":"7a31f4d224d3265b","repo":"litedb-org/LiteDB","slug":"0-7a31f4","errorCode":"0","errorMessage":"Invalid connection string value type for `{key}`","messagePattern":"Invalid connection string value type for `(.+?)`","errorType":"exception","errorClass":"LiteException","httpStatus":null,"severity":"error","filePath":"LiteDB/Utils/Extensions/DictionaryExtensions.cs","lineNumber":165,"sourceCode":"                    }\n                    else\n                    {\n                        return (T)(object)TimeSpan.Parse(value);\n                    }\n                }\n                else if (typeof(T).GetTypeInfo().IsEnum)\n                {\n                    return (T)Enum.Parse(typeof(T), value, true);\n                }\n                else\n                {\n                    return (T)Convert.ChangeType(value, typeof(T));\n                }\n            }\n            catch (Exception)\n            {\n                //TODO: fix string connection parser\n                throw new LiteException(0, $\"Invalid connection string value type for `{key}`\");\n            }\n        }\n\n        /// <summary>\n        /// Get a value from a key converted in file size format: \"1gb\", \"10 mb\", \"80000\"\n        /// </summary>\n        public static long GetFileSize(this Dictionary<string, string> dict, string key, long defaultValue)\n        {\n            var size = dict.GetValue<string>(key, null);\n\n            if (size == null) return defaultValue;\n\n            var match = Regex.Match(size, @\"^(\\d+)\\s*([tgmk])?(b|byte|bytes)?$\", RegexOptions.IgnoreCase);\n\n            if (!match.Success) return 0;\n\n            var num = Convert.ToInt64(match.Groups[1].Value);\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Utils/Extensions/DictionaryExtensions.cs#L147-L183","documentation":"Thrown by DictionaryExtensions.GetValue<T> (used by the connection string parser) when converting a connection string key's string value to the requested type T fails - TimeSpan parse, enum parse, or Convert.ChangeType all throw, and the generic catch rethrows as this LiteException. It signals a malformed connection string value for a typed setting.","triggerScenarios":"Connection string values that cannot parse to their target type: timeout='abc' (not a TimeSpan/number), a non-numeric value for an int setting (e.g. cache size='big'), an invalid enum name for an enum-typed connection option.","commonSituations":"Typos in connection string values; copy-pasting a setting name/value between versions where the type changed; locale-specific number formats; passing units where a plain int is expected or vice-versa.","solutions":["Check the documented type for each connection string key and supply a parseable value.","For numeric sizes use the file-size syntax supported by GetFileSize (e.g. '10MB') where applicable, or plain integers otherwise.","Validate/trim the connection string at config load time; log the offending key.","Remove the problematic key to fall back to its default."],"exampleFix":"// before\nvar db = new LiteDatabase(\"Filename=app.db;Timeout=soon\"); // throws\n\n// after\nvar db = new LiteDatabase(\"Filename=app.db;Timeout=00:01:00\");","handlingStrategy":"try-catch","validationCode":"static bool TryParseConnValue<T>(string raw, out T value) {\n    try { value = (T)Convert.ChangeType(raw, typeof(T)); return true; }\n    catch { value = default; return false; }\n}\n// validate each typed key before constructing LiteDatabase","typeGuard":null,"tryCatchPattern":"try { var db = new LiteDatabase(connStr); }\ncatch (LiteException ex) when (ex.Message.Contains(\"Invalid connection string value type\")) {\n    // read ex.Message key, correct the value, rebuild connStr\n}","preventionTips":["Centralize connection string building and unit-test each typed key.","Use file-size syntax (e.g. 10MB) where the parser supports it.","Log the offending key when construction fails."],"tags":["connection-string","config","type-conversion","parsing"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}