Unable to decode attachment


I’m getting Unable to decode Attachment errors when I try to manipulate attachments on CBL 1.4, .NET through an iOS app,

My current scenario is as follows :

  1. User A has access to a list of “Task” documents
  2. User A has an attachment “profile_pic.jpg”
  3. “Task” documents have attachments “task_pic.jpg” & “profile_pic.jpg” (which is the profile pic of User A)
  4. When User A changes their profile picture, i need to update all “Task” documents User A has access to. So I update User A’s document through the id, and add another attachment into the “Task” documents by iterating over their ids.

Here’s how I’m updating User A document :

        var ImageData = myImage.AsJPEG();
	var Revision = UserDocument.CurrentRevision.CreateRevision();
	Revision.SetAttachment(Constants.PROFILE_PIC_ATT_KEY, "image/jpeg", ImageData);
        //Revision.RemoveAttachment(Constants.PROFILE_PIC_ATT_KEY); (for Removal)

And the Task Documents:

    foreach(id in TaskIds)
        var taskDoc = Database.GetDocument(id);
	var revision = taskDoc.CurrentRevision.CreateRevision();
        revision.SetAttachment(Constants.PROFILE_PIC_ATT_KEY, "image/jpeg", ImageData);
        //revision.RemoveAttachment(Constants.PROFILE_PIC_ATT_KEY); (for Removal)

where Constants.PROFILE_PIC_ATT_KEY is “profile_pic.jpg”

When the profile picture changes, everything is good, everything is as expected.

But when I manually rerun the livequery for the tasks, i get Unable to decode attachment for “task_pic.jpg”, when i haven’t even touched that attachment. What I noticed though is when I rerun the livequery, i get an extra “_revisions” property from the document, where as I could only see " _rev" previously.

When I update the task document, things are back to normal. But when I rerun the livequery again, I get the same behavior as described above, unable to decode attachment and then the extra “_revisions” property shows up

When I restart the app, everything’s fine. no extra “_revisions” property, and the “task_pic.jpg” attachment shows up just fine, properly decoded.

If i change a property through the admin console, things go back to normal.

Looks like this is a bug. Or am I doing something wrong here?

Any help would be much appreciated.