{"record":{"id":"4d63ef3a9af07b13","repo":"tursodatabase/turso","slug":"partial-sync-requires-bootstrapifempty-true","errorCode":null,"errorMessage":"Partial sync requires BootstrapIfEmpty=True.","messagePattern":"Partial sync requires BootstrapIfEmpty=True\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs","lineNumber":181,"sourceCode":"            throw new InvalidOperationException(\n                \"Auth Token requires an HTTPS sync URL unless the host is localhost or loopback.\");\n        }\n\n        if (LongPollTimeout is { } timeout\n            && (timeout < TimeSpan.FromMilliseconds(1) || timeout.TotalMilliseconds > int.MaxValue))\n        {\n            throw new ArgumentOutOfRangeException(\n                nameof(LongPollTimeout),\n                timeout,\n                $\"Long-poll timeout must be between 1 and {int.MaxValue} milliseconds.\");\n        }\n\n        ValidateNativeSize(PushOperationsThreshold, nameof(PushOperationsThreshold));\n        ValidateNativeSize(PullBytesThreshold, nameof(PullBytesThreshold));\n        PartialSync?.Validate();\n\n        if (PartialSync is not null && !BootstrapIfEmpty)\n            throw new InvalidOperationException(\"Partial sync requires BootstrapIfEmpty=True.\");\n        if (PartialSync is not null && RemoteEncryption is not null)\n            throw new InvalidOperationException(\"Partial sync cannot be combined with remote encryption.\");\n        if (PartialSync?.Query is not null && PullBytesThreshold.HasValue)\n        {\n            throw new InvalidOperationException(\n                \"PullBytesThreshold cannot be combined with query partial bootstrap.\");\n        }\n        if (PartialSync is not null && OperatingSystem.IsWindows())\n        {\n            throw new PlatformNotSupportedException(\n                \"Partial sync on Windows requires native sparse-file hole detection that is not yet implemented.\");\n        }\n\n        RemoteEncryption?.Validate();\n    }\n\n    private static void ValidateNativeSize(long? value, string parameterName)\n    {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/tursodatabase/turso/blob/c1e59287258d99b309e362a63f48822256e2f65f/bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs#L163-L199","documentation":"Validate requires that when PartialSync is configured, BootstrapIfEmpty is true. Partial sync bootstraps a fresh local replica by pulling only the specified prefix/query, which inherently depends on the bootstrap-if-empty flow; disabling it while requesting partial sync is contradictory and rejected.","triggerScenarios":"Constructing TursoSyncDatabaseOptions with PartialSync = new TursoPartialSyncOptions { ... } and BootstrapIfEmpty = false — TursoSyncDatabaseOptions.cs:180-181.","commonSituations":"Turning off BootstrapIfEmpty to avoid touching an existing local file while separately enabling partial sync, partial-sync snippets copied into configs that already disabled bootstrap.","solutions":["Remove BootstrapIfEmpty = false (default is true) when using PartialSync.","If bootstrap must stay off, remove the PartialSync option and use a full sync instead."],"exampleFix":"// before\nvar opts = new TursoSyncDatabaseOptions(path, uri) { BootstrapIfEmpty = false, PartialSync = new() { PrefixLength = 100 } };\n// after\nvar opts = new TursoSyncDatabaseOptions(path, uri) { PartialSync = new() { PrefixLength = 100 } };","handlingStrategy":"validation","validationCode":"static void EnsurePartialSyncBootstrap(bool? bootstrapIfEmpty, object? partialSync)\n{\n    if (partialSync is not null && bootstrapIfEmpty == false)\n        throw new InvalidOperationException(\"PartialSync requires BootstrapIfEmpty=true.\");\n}","typeGuard":"static bool PartialSyncConfigIsValid(bool bootstrapIfEmpty, object? partialSync) => partialSync is null || bootstrapIfEmpty;","tryCatchPattern":"try { var db = new TursoSyncDatabase(opts); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"BootstrapIfEmpty\"))\n{\n    // drop BootstrapIfEmpty=false or drop PartialSync, then retry\n}","preventionTips":["Leave BootstrapIfEmpty at its default (true) whenever PartialSync is configured.","Centralize sync options construction in one factory so conflicting flags can't drift apart.","Document in team config templates that BootstrapIfEmpty=false excludes PartialSync."],"tags":["dotnet","sync","partial-sync","invalid-configuration"],"backgroundTag":"invalid-sync-options","analyzedSha":"c1e59287258d99b309e362a63f48822256e2f65f","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}