{"record":{"id":"0b222c0aea9fedfa","repo":"tursodatabase/turso","slug":"advanced-sync-options-require-an-embedded-replica","errorCode":null,"errorMessage":"Advanced sync options require an embedded replica connection.","messagePattern":"Advanced sync options require an embedded replica connection\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoConnection.cs","lineNumber":470,"sourceCode":"        }\n        catch\n        {\n            InvalidateRemoteSession();\n        }\n    }\n\n    private void OpenRemote()\n    {\n        if (_connectionOptions.IsReplica)\n        {\n            OpenReplica();\n            return;\n        }\n\n        if (_connectionOptions.SyncInterval > 0)\n            throw new NotSupportedException(\"Sync Interval requires an embedded replica connection.\");\n        if (_connectionOptions.HasAdvancedReplicaOptions)\n            throw new NotSupportedException(\"Advanced sync options require an embedded replica connection.\");\n\n        if (_connectionOptions.GetEncryptionCipher().HasValue || !string.IsNullOrWhiteSpace(_connectionOptions[\"Encryption Key\"]))\n            throw new InvalidOperationException(\"Encryption Cipher and Encryption Key are local database options and cannot be used with remote Turso URLs.\");\n\n        var handler = RemoteMessageHandlerFactory?.Invoke();\n        _remoteClient = handler is null\n            ? new TursoRemoteClient(_connectionOptions.GetRemoteUri(), _connectionOptions.AuthToken)\n            : new TursoRemoteClient(\n                new HttpClient(handler),\n                _connectionOptions.GetRemoteUri(),\n                _connectionOptions.AuthToken,\n                disposeHttpClient: true);\n    }\n\n    private void OpenReplica()\n    {\n        var lease = TursoReplicaRegistry\n            .AcquireAsync(","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoConnection.cs#L452-L488","documentation":"Advanced replica options (beyond basic SyncInterval) only make sense for an embedded replica that performs local syncs. OpenRemote rejects them when the data source is a remote Turso URL because there is no local replica to apply them to.","triggerScenarios":"Opening a TursoConnection with a remote URL while setting advanced replica options in the connection string (HasAdvancedReplicaOptions is true, e.g. sync-related tuning flags).","commonSituations":"Copy-pasting an embedded-replica connection string but changing the data source to a remote URL, enabling advanced sync settings globally and opening a remote-only connection, refactoring connection setup without cleaning up replica options.","solutions":["Remove the advanced replica options from the remote connection string.","Use the full embedded-replica connection string (local file + remote Uri) if those options are needed.","Move advanced option setup behind a check on connection type so they are only applied to replica connections."],"exampleFix":"// before\nvar cs = \"Data Source=turso://mydb-myorg.turso.io;SyncInterval=60;AdvancedSync=...\";\n// after\nvar cs = \"Data Source=turso://mydb-myorg.turso.io;\"; // remote only\n// or keep advanced options with:\nvar cs = \"Data Source=/local/replica.db;Uri=turso://mydb-myorg.turso.io;SyncInterval=60;AdvancedSync=...\";","handlingStrategy":"validation","validationCode":"var b = new DbConnectionStringBuilder { ConnectionString = cs };\nbool isRemote = (b[\"Data Source\"] as string ?? \"\").StartsWith(\"turso://\");\nbool hasAdvanced = /* any advanced replica keys present */ b.Keys.Cast<string>().Any(k => k.StartsWith(\"Sync\") && k != \"SyncInterval\");\nif (isRemote && hasAdvanced) throw new NotSupportedException(\"advanced replica options need a local replica\");","typeGuard":null,"tryCatchPattern":"try { conn.Open(); } catch (NotSupportedException ex) when (ex.Message.Contains(\"Advanced sync options\")) { /* remove advanced options or use embedded replica cs */ }","preventionTips":["Keep replica-only options co-located with replica connection builders.","Document which connection-string keys are replica-only.","Add a startup validation that rejects remote + replica-option mixes early."],"tags":["dotnet","embedded-replica","connection-string","configuration"],"backgroundTag":"invalid-connection-string-option","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}