How to recover from missing_stub / invalid attachment stub error

623 views
Skip to first unread message

Brendan Duddridge

unread,
Aug 19, 2016, 12:01:04 PM8/19/16
to Couchbase Mobile
Hi,

I'm syncing with Cloudant (CouchDB 2.0) and I think that CBL is sending it invalid attachment data, so I'm wondering what's the best way to recover from something like this? In the past if I can identify which attachment is having the problems I can delete it and re-add it and it works fine after that. But sometimes it's difficult to find the attachment that's causing the trouble. I know the document ID that's causing the problem.

Here's the error I'm getting:

NSErrorFailingURLKey=https://myaccount.cloudant.com/db-757c0197a63d47e48a9d98e2ca7c2042/_bulk_docs, CBLServerErrorInfo=<CFBasicHash 0x600000871000 [0x7fff7bd4d440]>{type = immutable dict, count = 2,

entries =>

0 : error = <CFString 0x6000006255e0 [0x7fff7bd4d440]>{contents = "missing_stub"}

2 : reason = <CFString 0x6000001077d0 [0x7fff7bd4d440]>{contents = "Invalid attachment stub in rec-c7b3f36ae6c64ce6b8590814a009b7f9 for 90655274-2EA4-4BC0-90CF-4D8448365E34~L0~001.jpeg"}

}


Any suggestions would be very welcome. Or is this perhaps a bug in CBL? Or CouchDB 2.0?

Thanks,

Brendan

Jens Alfke

unread,
Aug 21, 2016, 5:32:47 PM8/21/16
to mobile-c...@googlegroups.com
On Aug 19, 2016, at 12:01 PM, Brendan Duddridge <bren...@gmail.com> wrote:

But sometimes it's difficult to find the attachment that's causing the trouble. I know the document ID that's causing the problem.

Well, in the example you gave, the attachment name appears in the error info:

2 : reason = <CFString 0x6000001077d0 [0x7fff7bd4d440]>{contents = "Invalid attachment stub in rec-c7b3f36ae6c64ce6b8590814a009b7f9 for 90655274-2EA4-4BC0-90CF-4D8448365E34~L0~001.jpeg"}


The attachment appears to be "90655274-2EA4-4BC0-90CF-4D8448365E34~L0~001.jpeg”.

It appears to be CouchDB that’s complaining about the attachment metadata in the document; I don’t know what the reason would be.

—Jens

Brendan Duddridge

unread,
Aug 21, 2016, 7:19:13 PM8/21/16
to Couchbase Mobile
Well, the reason was "missing stub".

What exactly is the stub and how could it be missing?

Yes, I could parse the error message, but if they change that on the back-end, then it would fail.

I'm just wondering if perhaps CBL is sending invalid attachment data or has failed to send the "stub", whatever that is.

Thanks,

Brendan

Jens Alfke

unread,
Aug 22, 2016, 1:11:42 PM8/22/16
to mobile-c...@googlegroups.com

On Aug 21, 2016, at 4:19 PM, Brendan Duddridge <bren...@gmail.com> wrote:

Well, the reason was "missing stub".
What exactly is the stub and how could it be missing?

The ‘stub’ is the metadata in the document body, i.e. the object for that attachment in the ‘_attachments’ property. 
The error actually says “invalid stub”, not “missing”. It’s unclear from the message what CouchDB thinks is invalid about it.

—Jens

Brendan Duddridge

unread,
Aug 22, 2016, 1:26:48 PM8/22/16
to Couchbase Mobile
Hi Jens,

Actually in the full error message that I posted, the error did say "missing_stub":

0 : error = <CFString 0x6000006255e0 [0x7fff7bd4d440]>{contents = "missing_stub"}

It was the "reason" property that says "Invalid attachment stub...."

So it is missing according to CouchDB 2.0.

Thanks,

Brendan

Jens Alfke

unread,
Aug 22, 2016, 2:35:34 PM8/22/16
to mobile-c...@googlegroups.com

On Aug 22, 2016, at 10:26 AM, Brendan Duddridge <bren...@gmail.com> wrote:

Actually in the full error message that I posted, the error did say "missing_stub":

Oh, sorry. In that case it refers directly to the “stub”:true property that appears in the attachment metadata to indicate that the body of the attachment is deliberately not being sent. (The alternatives are to send the data inline by adding a “data” property, or by adding a “follows”:true property to indicate that the data is in a separate MIME part.)

Is there a way you can capture the entire request that produced the error, by using HTTPScoop or Charles Proxy or something?

—Jens

Brendan Duddridge

unread,
Aug 22, 2016, 4:13:51 PM8/22/16
to Couchbase Mobile
When it happens again (and I'm sure it will) I'll capture the request info from Charles Proxy. I had to delete the attachment to continue on with my work and the problem vanished for now when I replaced the attachment.

But it does keep coming back.
Reply all
Reply to author
Forward
0 new messages