Why is Document.PutProperties(...) returning null?

.net

#1

We are seeing situations where the Document.PutProperties method is returning null and no new revision is being created.

There are no errors in the Couchbase Lite logs that indicate any kind of error has occurred.

What could be causing this?


#2

Are there any attachments on the document? Which storage engine are you using? I’m not sure off the top of my head about why it would return null. Usually if something was wrong there would be an exception.


#3

Yes, there are attachments. It looks like if there is an attachment in the _attachments metadata property that is not recognized by CBLite (or it can’t find it), then PutProperties will return null.

We are using SQLite.


#4

There was a recent issue involving the pusher corrupting attachments in the cached version of the document (not the persisted one). That might be coming into play here. There is no public API workaround (aside from closing and reopening the DB, which should work), but it has been fixed on the 1.x branch and there is a workaround that you can use that involves reflection if you are interested.


#5

We originally reported that issue, so we’re using the maintenance patch. Same behavior still.

Also, what is the expected behavior if the dictionary passed to PutProperties contains the “_revisions” property? I notice that the Document.Properties dictionary returns this private property.

More specifically, do we need to pass it in with every update to PutProperties, or can CBLite determine the revisions from some other cache that it maintains?


#6

The _revisions property is not needed for the document to know its history in that context. The _revisions property is purely for communication between server and client. There is no expected behavior for any property except that underscore properties are reserved for Couchbase use. This key in particular is stripped out before the save takes place.

Note that a lot of bad behavior gets logged at the WARNING level and not the ERROR level.


#7

Good to know.

I also have the same question regarding the _attachments property then…

What would happen if the document contains attachments, but a call to PutProperties is made that omits the _attachments property? Are the actual attachments still preserved?

It seems that due to the behavior I initially describe that CBLite does read this value and attempt to lookup attachment details from somewhere. Just wondering if I omit the value from the saved properties if that would result in some kind of failure either directly or later down the road.


#8

If you omit the _attachments then they will be removed. Each revision completely rewrites the last.