Corrupt Revision Data error when saving documents

SDK: Couchbase Lite C
Version: 3.0.2
OS: iOS & Android
Error: kCBLErrorCorruptRevisionData

This error has only been observed through error reports from user devices, and I have not been able to replicate it.

It seems that saving a document can sometimes corrupt it, since after the first time this error has been returned when saving a document, subsequent attempts to save the document always fail with the same error. The document can still be purged, though.

There are also crashes in CBLDatabase_SaveDocumentWithConcurrencyControl and CBLDocument::properties that seem related. It would make sense to me that once a document has been corrupted, invariants that certain code relies on don’t hold anymore.

The error message only contains the error code. Looking at the source code, only in a few places is a corruptRevisionData error thrown without a message. Additional logging or an error message describing the problem might be the first step to diagnose the issue.

To solve this issue, we will need to be able to reproduce the issue or know the sequence of events that lead to the issue. I agreed that adding error message along with the error code would be the first step.

Do you have a log that you can share?

I don’t have full log files, just log messages of log level info and above. But I might be able to capture and provide a database with a corrupted document in it. That would allow replication of the error.

That could be helpful at least to see what rev info is missing.