404 missing with attachments=true instead of _attachments=true

39 views
Skip to first unread message

thomas....@teckeezy.com

unread,
Feb 20, 2015, 4:54:50 AM2/20/15
to mobile-c...@googlegroups.com


Hello all,

We are currently working with cbmobile 1.0 & sync gateway 1.0 (yes I know we should upgrade and we will very soon -- problem of compatibility with iOS 6 involved).

It was working perfectly but I reinititialized my sync bucket recently and it won't work anymore : I see that my iOS app makes request like this one :

/sync_gateway/86B20DD2-AE8B-4644-848E-A104BB55AD1C?rev=1-2ec9d67b22891831614ad5bbd4453928&revs=true&attachments=true

and gets a 

--> 404 missing  (0.0 ms)

as response

If I request manually the url :

http://preprod.storyplayr.com/sync_gateway/86B20DD2-AE8B-4644-848E-A104BB55AD1C?rev=1-2ec9d67b22891831614ad5bbd4453928&revs=true&attachments=true

I get a 404 also but if I replace attachments with _attachments, I get the doc as an answer...

Do you know what is going on ? Why does the request with attachments does not work ?

Thanks for you answer.


Thomas

ajres

unread,
Feb 20, 2015, 5:08:04 AM2/20/15
to mobile-c...@googlegroups.com
I tried the public URL but I get 404 missing for all permutations even just the plain doc id.

After you re-initialized the bucket, how did you re-populate the documents?

Andy

thomas....@teckeezy.com

unread,
Feb 20, 2015, 7:17:53 AM2/20/15
to mobile-c...@googlegroups.com
Sorry, the actual URL is :

http://preprod.storyplayr.com:4984/sync_gateway/86B20DD2-AE8B-4644-848E-A104BB55AD1C?rev=1-2ec9d67b22891831614ad5bbd4453928&revs=true&attachments=true

(the port was missing)

But it is password protected.

This is the answer I get with _attachments=true :
{"_attachments":{"detail.jpg":{"content_type":"image/jpg","digest":"sha1-051h0Z+NQSCxhLG4T2KaQ/t//pI=","length":37981,"revpos":62,"stub":true},"det...@2x.jpg":{"content_type":"image/jpg","digest":"sha1-AB9fKIoAixcsqZGQSvFRZuCOsxU=","length":110003,"revpos":62,"stub":true}},"_id":"86B20DD2-AE8B-4644-848E-A104BB55AD1C","_rev":"1-2ec9d67b22891831614ad5bbd4453928","_revisions":{"ids":["2ec9d67b22891831614ad5bbd4453928"],"start":1},"age":6,"authors":["C2984BFB-791E-44AD-9D17-21A9A4F604B7"],"bgcolor":"#010100","channels":["public","preload"],"editor":"ECC82E13-4050-4B27-A639-76293F5F27C8","indexPreview1":2,"indexPreview2":9,"indexPreview3":15,"isbn":null,"model_type":"Story","pageCount":22,"pages":["8747CA83-E0E2-470F-9397-D51FA61B4C04","8FBBC2BA-6738-409B-BDE7-5160EA39F490","0D2E4C44-BB4A-403F-A227-623C32A5B57B","34E447D8-732A-42E8-9E63-1191B6E352DF","69B61A60-12B8-41E4-B6C5-75869018F042","972C49DA-21F7-48FE-B801-863458670A7F","DBF190CA-390E-4DF6-A3BB-E14BC6B60D07","E128357F-4B6E-486D-B614-DCAE84ED3912","113E185A-1843-4726-82DF-1EDAFA32B735","52E98E38-13ED-4B1F-82C9-C744F4C61981","490150B6-0CA4-44EE-9CA0-E91F5358961A","6AD49D5F-0B00-4F81-9862-0E1CD569AE04","7EFDFEBF-E402-4DA7-8449-E57AA8A8D84B","EADA93BB-FC31-4521-982C-423A4C3CE8A8","BA6F6E52-7E3A-49F5-831F-C0742D5E10D9","B7FB9047-E170-43C9-AEA4-E2FF8537C0F8","A39FCE92-82BA-4129-B77A-E101D3AFEAEC","BF0DF620-AB63-4132-993B-A74FDCB2AB34","D2C40E4B-27EA-4225-924E-25DADE34AC4A","9F33094F-7321-41C7-83F6-CA762D52014D","7987DF4F-F79B-4921-A596-0380FDFC7E9D","D7EFB947-A269-48AE-840D-80AD8FECF13C"],"permalink":"1001-crepes-pour-la-lune","publicationStatus":1,"publishingDate":"2015-01-01","summary":"Dans l'Egypte antique, sur les bords du Nil, une petite fille, Dasine, et son petit frère, Bakou, sont faits prisonniers par une sorcière cannibale.\r\nDasine parvient à s'enfuir seule dans le désert, où elle rencontre la Déesse Lune.\r\nCette dernière lui confie la recette des crêpes qui gaveront la sorcière et la mettront hors d'état de nuire.","tags":["242551F7-3606-45E5-B2A4-52D00634CFBD","46548228-B5AA-4F37-B021-27B81B0BDFF8","61AFFD89-BC55-49B6-BDCE-E47B83E1B3A2","CD35C970-9AC9-4667-B221-1F9FD22E1766","F83591E9-68BA-4B01-AE92-D764B44A64A8"],"text":null,"title":"1001 crêpes pour la lune"}


After re-initializing the bucket, I just restarted sync gateway which re-indexed everything automatically... I had already done it multiple times with no problems...

Thanks,

Jens Alfke

unread,
Feb 20, 2015, 12:24:27 PM2/20/15
to mobile-c...@googlegroups.com

On Feb 20, 2015, at 1:54 AM, thomas....@teckeezy.com wrote:

I get a 404 also but if I replace attachments with _attachments, I get the doc as an answer…

Changing it to “_attachments” is the same as removing that query parameter entirely, because “_attachments” isn’t a parameter the gateway looks for. Without “attachments=true”, the default behavior is to send the document but without the bodies of attachments.

It sounds like what’s happening is that one of the attachments is missing from the bucket, causing the entire request to fail. Each attachment is stored in the bucket under a key that’s “_sync:att:” plus the attachment’s ‘digest’ property. So use the Couchbase admin UI to look in the bucket and see if you can find
_sync:att:sha1-051h0Z+NQSCxhLG4T2KaQ/t//pI=
_sync:att: sha1-AB9fKIoAixcsqZGQSvFRZuCOsxU=
If either is missing, something weird’s going on…

—Jens

thomas....@teckeezy.com

unread,
Feb 20, 2015, 1:26:49 PM2/20/15
to mobile-c...@googlegroups.com
Hi Jens,

Ok, I understand.

I did what you suggested and indeed the attachment is not there.

My storyplayer-sync bucket has been regenerated by sync gateway from my storyplayer-api bucket. Maybe something went wrong there ? How can I request through the couchbase admin UI the attachments in the storyplayer-api bucket ?

If it's missing from storyplayer-api bucket, then something went wrong when restoring by backup... (fortunately i am talking of a preprod environment.

Thanks Jens

Thomas

Jens Alfke

unread,
Feb 20, 2015, 2:36:32 PM2/20/15
to mobile-c...@googlegroups.com

On Feb 20, 2015, at 10:26 AM, thomas....@teckeezy.com wrote:

My storyplayer-sync bucket has been regenerated by sync gateway from my storyplayer-api bucket. Maybe something went wrong there ? How can I request through the couchbase admin UI the attachments in the storyplayer-api bucket ?

I’m not quite sure what this means. Are you talking about bucket-shadowing? I believe that attachments are not copied to the ‘public’ bucket; they only remain in the gateway’s private bucket. Were you looking in the private bucket?

—Jens

thomas....@teckeezy.com

unread,
Feb 20, 2015, 5:58:54 PM2/20/15
to mobile-c...@googlegroups.com
Ok, let me give you an overview of our project : We have a webapp and an iOS app.

iOS app works with couchbaselite synced with our storyplayer-sync couchbase bucket

Webapp works in with node.js with our storyplayer-api bucket except considering attachments. Because couchbase does not support attachment upload/download, we have to go through sync-gateway.

storyplayer-api and storyplayer-sync are "shadowed".

I am very surprised when you say that attachments are not copied in the storyplayer-api bucket. Because I believe I have already done this process before when doing building a preprod database from the prod database :
- deleting both bucket in preprod environment
- taking the storyplayer-api backup from the prod and restoring it in the preprod environment
- restarting sync-gateway 
- storyplayer-sync is then rebuilt and usually attachments were mirrored with the rest of the data (I think so...).

But maybe I am wrong... Are you definite about the fact that in a "shadow" config, the attachments are not copied from the sync gateway bucket to the original one ?

Thanks for your answers and your help with this beautiful (but sometimes hard to grasp) technology.

Thomas
Reply all
Reply to author
Forward
0 new messages