{"record":{"id":"7bdee18cc9f9e0a4","repo":"tursodatabase/turso","slug":"unknown-turso-sync-operation-state","errorCode":null,"errorMessage":"Unknown Turso sync operation state.","messagePattern":"Unknown Turso sync operation state\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoSyncDatabase.cs","lineNumber":360,"sourceCode":"        TursoSyncOperationKind operationKind,\n        CancellationToken cancellationToken)\n    {\n        try\n        {\n            while (true)\n            {\n                cancellationToken.ThrowIfCancellationRequested();\n                switch (TursoSyncBindings.Resume(operation))\n                {\n                    case TursoSyncOperationState.Done:\n                        return;\n                    case TursoSyncOperationState.Continue:\n                        continue;\n                    case TursoSyncOperationState.Io:\n                        await ProcessIoQueueAsync(cancellationToken).ConfigureAwait(false);\n                        break;\n                    default:\n                        throw new InvalidOperationException(\"Unknown Turso sync operation state.\");\n                }\n            }\n        }\n        catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)\n        {\n            try\n            {\n                CancelQueuedIo();\n            }\n            catch\n            {\n                // Preserve cancellation after making the best effort to release native callbacks.\n            }\n            throw;\n        }\n        catch (TursoSyncException)\n        {\n            throw;","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoSyncDatabase.cs#L342-L378","documentation":"DriveOperationAsync loops over states returned by a sync operation handle (Ok/Continue/Io handled above). If the underlying runtime ever returns a TursoSyncOperationState the .NET driver does not recognize, it throws InvalidOperationException as a defensive default — meaning the native/Rust core and the .NET enum are out of sync.","triggerScenarios":"A sync operation (PullAsync, GetStatsAsync, ConnectHandleAsync, RunVoidOperationAsync) yields an operation state value not covered by the switch (only Continue and Io are matched in the shown default path), typically from a newer native library with new states used against an older managed binding.","commonSituations":"Version mismatch between the native turso library and the Turso.Data package; corrupted or unexpectedly completed sync operation handles.","solutions":["Align versions: update the Turso.Data NuGet package and the native turso library to matching releases.","If pinning native libraries (e.g. via custom build), rebuild both from the same source revision.","Reproduce with a minimal sync workload and report upstream if versions already match."],"exampleFix":"// before\n<PackageReference Include=\"Turso.Data\" Version=\"0.1.0\" /> + mismatched native lib\n// after\n<PackageReference Include=\"Turso.Data\" Version=\"0.2.0\" /> // matching native library","handlingStrategy":"try-catch","validationCode":"// check versions before opening\nvar managed = typeof(TursoConnection).Assembly.GetName().Version;\n// ensure the pinned native turso library matches the managed package version","typeGuard":null,"tryCatchPattern":"try\n{\n    await connection.SyncAsync(ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unknown Turso sync operation state\"))\n{\n    throw new InvalidOperationException(\"Native library and Turso.Data versions are out of sync. Align both.\", ex);\n}","preventionTips":["Ship the native library bundled with the NuGet package; never mix versions.","Pin both managed and native artifacts to the same release in CI."],"tags":["dotnet","sync","version-mismatch","state-machine"],"backgroundTag":"unknown-operation-state","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"}