{"record":{"id":"09d1cfdca35cbbc8","repo":"tursodatabase/turso","slug":"pullbytesthreshold-cannot-be-combined-with-query-p","errorCode":null,"errorMessage":"PullBytesThreshold cannot be combined with query partial bootstrap.","messagePattern":"PullBytesThreshold cannot be combined with query partial bootstrap\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs","lineNumber":186,"sourceCode":"            && (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    {\n        if (value is null)\n            return;\n        if (value <= 0)\n            throw new ArgumentOutOfRangeException(parameterName, value, \"The value must be positive.\");\n        if ((ulong)value > nuint.MaxValue)","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/tursodatabase/turso/blob/c1e59287258d99b309e362a63f48822256e2f65f/bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs#L168-L204","documentation":"When PartialSync uses a Query bootstrap strategy, Validate forbids also setting PullBytesThreshold. The query bootstrap defines exactly what to pull, so a byte-threshold pull limit would conflict with it; the combination throws InvalidOperationException.","triggerScenarios":"Constructing TursoSyncDatabaseOptions with PartialSync.Query set (e.g. \"WHERE tenant_id = 1\") and a non-null PullBytesThreshold (e.g. PullBytesThreshold = 1_000_000) — TursoSyncDatabaseOptions.cs:184-188.","commonSituations":"Adding a size cap to try to limit query-bootstrap pulls, merging a partial-sync config that used byte thresholds with one that uses queries.","solutions":["Remove PullBytesThreshold when PartialSync.Query is set.","Use PrefixLength bootstrap instead of Query if you want byte/segment-based thresholds alongside partial sync.","Constrain the query itself (e.g. tighter WHERE clause) instead of using a byte threshold."],"exampleFix":"// before\nvar opts = new TursoSyncDatabaseOptions(path, uri)\n{\n    PullBytesThreshold = 1_000_000,\n    PartialSync = new() { Query = \"SELECT * FROM events WHERE tenant_id = 1\" }\n};\n// after\nvar opts = new TursoSyncDatabaseOptions(path, uri)\n{\n    PartialSync = new() { Query = \"SELECT * FROM events WHERE tenant_id = 1\" }\n};","handlingStrategy":"validation","validationCode":"static void EnsureQueryBootstrapHasNoByteThreshold(TursoPartialSyncOptions? partialSync, long? pullBytesThreshold)\n{\n    if (partialSync?.Query is not null && pullBytesThreshold.HasValue)\n        throw new InvalidOperationException(\"Drop PullBytesThreshold when using a query bootstrap.\");\n}","typeGuard":"static bool PartialThresholdComboIsValid(TursoPartialSyncOptions? ps, long? pullBytes) => ps?.Query is null || !pullBytes.HasValue;","tryCatchPattern":"try { var db = new TursoSyncDatabase(opts); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"PullBytesThreshold\"))\n{\n    // remove PullBytesThreshold or switch to PrefixLength bootstrap\n}","preventionTips":["Use PullBytesThreshold only with prefix-based (PrefixLength) partial sync.","Constrain query-bootstrapped pulls through the SQL query itself, not byte limits.","Keep one canonical partial-sync config per bootstrap strategy in your codebase."],"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-14T05:17:10.506Z"}