{"record":{"id":"b0239b0cd918ae31","repo":"tursodatabase/turso","slug":"remote-turso-urls-must-not-include-query-strings-o","errorCode":null,"errorMessage":"Remote Turso URLs must not include query strings or fragments.","messagePattern":"Remote Turso URLs must not include query strings or fragments\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoConnectionOptions.cs","lineNumber":134,"sourceCode":"        {\n            throw new InvalidOperationException(\n                \"Remote Encryption Cipher and Remote Encryption Key must be specified together.\");\n        }\n\n        return new TursoRemoteEncryptionOptions\n        {\n            Cipher = TursoRemoteEncryptionOptions.ParseCipher(cipher),\n            Key = key,\n        };\n    }\n\n    public Uri GetRemoteUri()\n    {\n        if (!Uri.TryCreate(DataSource, UriKind.Absolute, out var uri) || !IsRemoteScheme(uri.Scheme))\n            throw new InvalidOperationException($\"Data Source is not a remote Turso URL: {DataSource}\");\n\n        if (!string.IsNullOrEmpty(uri.Query) || !string.IsNullOrEmpty(uri.Fragment))\n            throw new InvalidOperationException(\"Remote Turso URLs must not include query strings or fragments.\");\n        if (!string.IsNullOrEmpty(uri.UserInfo))\n            throw new InvalidOperationException(\"Remote Turso URLs must not include embedded user information; use Auth Token instead.\");\n        if (string.IsNullOrEmpty(uri.Host))\n            throw new InvalidOperationException(\"Remote Turso URLs must include a host.\");\n\n        var scheme = uri.Scheme.ToLowerInvariant() switch\n        {\n            \"libsql\" => Tls == false ? \"http\" : \"https\",\n            \"turso\" => ValidateTls(uri.Scheme, expectedTls: true, normalizedScheme: \"https\"),\n            \"http\" => ValidateTls(uri.Scheme, expectedTls: false),\n            \"https\" => ValidateTls(uri.Scheme, expectedTls: true),\n            \"ws\" => ValidateTls(uri.Scheme, expectedTls: false, normalizedScheme: \"http\"),\n            \"wss\" => ValidateTls(uri.Scheme, expectedTls: true, normalizedScheme: \"https\"),\n            _ => throw new InvalidOperationException($\"Unsupported remote Turso URL scheme: {uri.Scheme}\")\n        };\n\n        var builder = new UriBuilder(uri)\n        {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoConnectionOptions.cs#L116-L152","documentation":"GetRemoteUri() rejects remote Turso URLs that contain a query string ('?...') or a fragment ('#...'). The remote pipeline authenticates via the Authorization header and normalizes the URL through UriBuilder, so it has no way to carry extra URL components; their presence almost always means config written for a different libsql client. The token belongs in the 'Auth Token' connection keyword, not in the URL.","triggerScenarios":"Opening a connection whose Data Source is e.g. 'libsql://db.turso.io?auth=eyJhbGci...' or 'https://db.turso.io/mydb#section' — any absolute libsql/http/https/ws/wss URL with a non-empty Uri.Query or Uri.Fragment triggers the exception.","commonSituations":"Copying a URL from the libsql TypeScript or Python clients, which accept the auth token as a '?auth=' query parameter; pasting a dashboard URL that carries a '#fragment'; appending instance or cache-busting parameters to the database URL.","solutions":["Remove the query string and fragment so the URL is bare scheme://host/path.","Move the auth token into the connection string: 'Auth Token=eyJ...' (or 'DataSource=...;AuthToken=...').","If you copied the URL from another libsql SDK, re-check which parts of it are meant to be connection keywords instead."],"exampleFix":"// before\nData Source=libsql://db.turso.io?auth=eyJhbGciOiJ...;\n\n// after\nData Source=libsql://db.turso.io;Auth Token=eyJhbGciOiJ...;","handlingStrategy":"validation","validationCode":"var raw = config[\"Turso:Url\"]!;\nvar sanitized = raw.Split('?', '#')[0]; // strip query/fragment before building the connection string\nvar cs = $\"Data Source={sanitized};Auth Token={config[\"Turso:Token\"]}\";","typeGuard":null,"tryCatchPattern":"try { await conn.OpenAsync(ct); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"query strings or fragments\")) { /* log that the URL carried a query/fragment; point to Auth Token keyword */ }","preventionTips":["Never hand-assemble Turso URLs from other SDKs' formats; store host and token as separate config values.","If a URL is user-supplied, sanitize with Split('?', '#') at ingestion."],"tags":["csharp","dotnet","connection-string","url-validation","auth-token"],"backgroundTag":"invalid-connection-url","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}