{"record":{"id":"22dbc7211d55d989","repo":"tursodatabase/turso","slug":"unsupported-sync-url-scheme-uri-scheme","errorCode":null,"errorMessage":"Unsupported sync URL scheme: {uri.Scheme}","messagePattern":"Unsupported sync URL scheme: (.+?)","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoSyncDatabase.cs","lineNumber":785,"sourceCode":"                \"Auth Token requires HTTPS sync requests unless the host is localhost or loopback.\");\n        }\n    }\n\n    private static bool HasSameOrigin(Uri left, Uri right)\n    {\n        return left.Scheme.Equals(right.Scheme, StringComparison.OrdinalIgnoreCase)\n               && left.IdnHost.Equals(right.IdnHost, StringComparison.OrdinalIgnoreCase)\n               && left.Port == right.Port;\n    }\n\n    private static Uri NormalizeRemoteUri(Uri uri)\n    {\n        var scheme = uri.Scheme.ToLowerInvariant() switch\n        {\n            \"turso\" or \"libsql\" => Uri.UriSchemeHttps,\n            \"http\" => Uri.UriSchemeHttp,\n            \"https\" => Uri.UriSchemeHttps,\n            _ => throw new InvalidOperationException($\"Unsupported sync URL scheme: {uri.Scheme}\"),\n        };\n        return new UriBuilder(uri)\n        {\n            Scheme = scheme,\n            Port = uri.IsDefaultPort ? -1 : uri.Port,\n            UserName = string.Empty,\n            Password = string.Empty,\n        }.Uri;\n    }\n\n    private static Uri CombineUri(Uri baseUri, string path)\n    {\n        var baseText = baseUri.GetLeftPart(UriPartial.Path).TrimEnd('/');\n        return new Uri(baseText + \"/\" + path.TrimStart('/'), UriKind.Absolute);\n    }\n\n    internal static TursoSyncDatabaseConfiguration CreateNativeConfiguration(\n        TursoSyncDatabaseOptions options,","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoSyncDatabase.cs#L767-L803","documentation":"When normalizing the remote URI, TursoSyncDatabase maps known schemes (turso, libsql -> https; http -> http; https -> https). Any other scheme is rejected with this InvalidOperationException because the sync transport only knows how to speak HTTP(S).","triggerScenarios":"Constructing TursoSyncDatabase with a remote URI whose scheme is not one of turso, libsql, http, or https, e.g. file:///path/to/db, ws://host, postgres://host, or a misspelled scheme like htts://host.","commonSituations":"Copy-pasting a file:// path as the remote; typos in the scheme; reusing a connection string intended for another driver (postgres://, mysql://); shell variable interpolation leaving a malformed URL.","solutions":["Use one of the supported schemes: turso://, libsql://, https://, or http:// (http only for testing/local)","Replace file:// or other scheme with the correct https URL of the sync remote","Check for typos in the scheme string (htts, httpss, etc.)","Validate the URI with Uri.TryCreate and check the scheme before constructing options"],"exampleFix":"// before\nvar options = new TursoSyncDatabaseOptions(path, new Uri(\"postgres://db.example.com/mydb\"));\n// after\nvar options = new TursoSyncDatabaseOptions(path, new Uri(\"https://db.example.com\"));","handlingStrategy":"validation","validationCode":"bool TryNormalizeRemote(string url, out Uri normalized)\n{\n    normalized = null!;\n    if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) return false;\n    return uri.Scheme is \"turso\" or \"libsql\" or \"http\" or \"https\" && (normalized = uri) is not null;\n}\n// if (!TryNormalizeRemote(configValue, out var remote)) throw new ArgumentException($\"Unsupported sync URL scheme in '{configValue}'\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var db = new TursoSyncDatabase(options);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Unsupported sync URL scheme\"))\n{\n    logger.LogError(ex, \"Remote URI scheme is not supported; use turso://, libsql://, https:// or http://\");\n    throw;\n}","preventionTips":["Store remotes with explicit schemes in config; never accept bare hostnames","Validate scheme against {turso, libsql, http, https} at configuration load time","Watch for scheme typos (htts, httpss) in hand-edited config"],"tags":["dotnet","sync","url","configuration"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}