tursodatabase/turso · error · InvalidOperationException

Partial sync cannot be combined with remote encryption.

Error message

Partial sync cannot be combined with remote encryption.

What it means

Validate rejects combining PartialSync with RemoteEncryption. The two features are not implemented together: partial sync's selective pull path does not support decrypting remotely encrypted data, so any configuration specifying both is refused with InvalidOperationException.

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs:183

        }

        if (LongPollTimeout is { } timeout
            && (timeout < TimeSpan.FromMilliseconds(1) || timeout.TotalMilliseconds > int.MaxValue))
        {
            throw new ArgumentOutOfRangeException(
                nameof(LongPollTimeout),
                timeout,
                $"Long-poll timeout must be between 1 and {int.MaxValue} milliseconds.");
        }

        ValidateNativeSize(PushOperationsThreshold, nameof(PushOperationsThreshold));
        ValidateNativeSize(PullBytesThreshold, nameof(PullBytesThreshold));
        PartialSync?.Validate();

        if (PartialSync is not null && !BootstrapIfEmpty)
            throw new InvalidOperationException("Partial sync requires BootstrapIfEmpty=True.");
        if (PartialSync is not null && RemoteEncryption is not null)
            throw new InvalidOperationException("Partial sync cannot be combined with remote encryption.");
        if (PartialSync?.Query is not null && PullBytesThreshold.HasValue)
        {
            throw new InvalidOperationException(
                "PullBytesThreshold cannot be combined with query partial bootstrap.");
        }
        if (PartialSync is not null && OperatingSystem.IsWindows())
        {
            throw new PlatformNotSupportedException(
                "Partial sync on Windows requires native sparse-file hole detection that is not yet implemented.");
        }

        RemoteEncryption?.Validate();
    }

    private static void ValidateNativeSize(long? value, string parameterName)
    {
        if (value is null)
            return;

View on GitHub (pinned to c1e5928725)

Solutions

  1. Remove RemoteEncryption if you need partial sync.
  2. Remove PartialSync and use full sync if you need remote encryption.
  3. Check for newer library versions that may lift the restriction before working around it.

Example fix

// before
var opts = new TursoSyncDatabaseOptions(path, uri)
{
    PartialSync = new() { PrefixLength = 100 },
    RemoteEncryption = new() { Key = key, Cipher = TursoRemoteEncryptionCipher.Aes256Gcm }
};
// after
var opts = new TursoSyncDatabaseOptions(path, uri)
{
    RemoteEncryption = new() { Key = key, Cipher = TursoRemoteEncryptionCipher.Aes256Gcm }
};
Defensive patterns

Strategy: validation

Validate before calling

static void EnsureNotPartialPlusEncryption(object? partialSync, object? remoteEncryption)
{
    if (partialSync is not null && remoteEncryption is not null)
        throw new InvalidOperationException("PartialSync and RemoteEncryption cannot be combined.");
}

Type guard

static bool SyncFeatureComboIsValid(object? partialSync, object? remoteEncryption) => partialSync is null || remoteEncryption is null;

Try / catch

try { var db = new TursoSyncDatabase(opts); }
catch (InvalidOperationException ex) when (ex.Message.Contains("remote encryption"))
{
    // choose one feature and rebuild options
}

Prevention

When it happens

Trigger: Constructing TursoSyncDatabaseOptions with both PartialSync set (e.g. new TursoPartialSyncOptions { PrefixLength = N }) and RemoteEncryption = new TursoRemoteEncryptionOptions { Key = ..., Cipher = ... } — TursoSyncDatabaseOptions.cs:182-183.

Common situations: Adding encryption to an existing partial-sync replica setup after moving to an encrypted remote, combining sample configs from two different docs sections.

Related errors


AI-assisted analysis of tursodatabase/turso@c1e5928725 (2026-08-31). Data as JSON: /api/errors/78eebd1a04aaefc5. Report an issue: GitHub.