{"action":"opened","issue":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-net/issues/779","repository_url":"https://api.github.com/repos/couchbase/couchbase-lite-net","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-net/issues/779/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/couchbase-lite-net/issues/779/comments","events_url":"https://api.github.com/repos/couchbase/couchbase-lite-net/issues/779/events","html_url":"https://github.com/couchbase/couchbase-lite-net/issues/779","id":192127651,"number":779,"title":"Attachments disappearing from docs when continuous pull is enabled","user":{"login":"ryanthompson0123","id":3884891,"avatar_url":"https://avatars.githubusercontent.com/u/3884891?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanthompson0123","html_url":"https://github.com/ryanthompson0123","followers_url":"https://api.github.com/users/ryanthompson0123/followers","following_url":"https://api.github.com/users/ryanthompson0123/following{/other_user}","gists_url":"https://api.github.com/users/ryanthompson0123/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanthompson0123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanthompson0123/subscriptions","organizations_url":"https://api.github.com/users/ryanthompson0123/orgs","repos_url":"https://api.github.com/users/ryanthompson0123/repos","events_url":"https://api.github.com/users/ryanthompson0123/events{/privacy}","received_events_url":"https://api.github.com/users/ryanthompson0123/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-28T21:55:10Z","updated_at":"2016-11-28T21:55:10Z","closed_at":null,"body":"I'm having an issue where pre-existing attachments are disappearing from documents on mobile devices when an edit to the document is made on the web (by posting to the sync gateway REST API). This only happens when the mobile user has a continuous pull replication running. I can reproduce this with Couchbase Lite .NET 1.3.1 using just a small test harness. Here are the steps to reproduce:\r\n\r\n1. Start a continuous pull replication on a mobile device.\r\n2. Create a new document in sync gateway (using PUT method).\r\n3. Attach a photo to the new document (using docid/attachmentName PUT method).\r\n\r\nNow, if you get the document in the sync gateway, it looks like this:\r\n```\r\n{\r\n  \"_attachments\": {\r\n    \"photo\": {\r\n      \"content_type\": \"image/jpeg\",\r\n      \"digest\": \"sha1-ItXuFlL2CL3ERlRgM4Zc51mND94=\",\r\n      \"length\": 734666,\r\n      \"revpos\": 2,\r\n      \"stub\": true\r\n    }\r\n  },\r\n  \"_id\": \"bd87de36-9309-42b5-9e70-807848f90c7b\",\r\n  \"_rev\": \"2-7ac57d1b2a5ab02ab396841cfff1d5b6\",\r\n  \"color\": \"Black\",\r\n  \"size\": \"Medium\",\r\n  \"type\": \"fruit\",\r\n  \"name\": \"Pomegranate\"\r\n}\r\n```\r\nThe mobile device should also now have the document (my setup is just replicating everything). The properties for the current revision look like this:\r\n\r\n```\r\n{\r\n  \"_attachments\": {\r\n    \"photo\": {\r\n      \"content_type\": \"image/jpeg\",\r\n      \"digest\": \"sha1-ItXuFlL2CL3ERlRgM4Zc51mND94=\",\r\n      \"length\": 734666,\r\n      \"revpos\": 2,\r\n      \"stub\": true\r\n    }\r\n  },\r\n  \"_id\": \"bd87de36-9309-42b5-9e70-807848f90c7b\",\r\n  \"_rev\": \"2-7ac57d1b2a5ab02ab396841cfff1d5b6\",\r\n  \"color\": \"Black\",\r\n  \"size\": \"Medium\",\r\n  \"type\": \"fruit\",\r\n  \"name\": \"Pomegranate\"\r\n}\r\n```\r\nSo at this point everything is fine. Continuing on:\r\n\r\n4. Make an edit to the document by posting to the sync gateway PUT API. For this operation specifically, I'm posting to `https://myserver.com:4985/mySyncGateway/bd87de36-9309-42b5-9e70-807848f90c7b?rev=2-7ac57d1b2a5ab02ab396841cfff1d5b6` and the body looks like this:\r\n```\r\n{\r\n  \"_attachments\": {\r\n    \"photo\": {\r\n      \"content_type\": \"image/jpeg\",\r\n      \"digest\": \"sha1-ItXuFlL2CL3ERlRgM4Zc51mND94=\",\r\n      \"length\": 734666,\r\n      \"revpos\": 2,\r\n      \"stub\": true\r\n    }\r\n  },\r\n  \"_id\": \"bd87de36-9309-42b5-9e70-807848f90c7b\",\r\n  \"_rev\": \"2-7ac57d1b2a5ab02ab396841cfff1d5b6\",\r\n  \"color\": \"Red\",\r\n  \"size\": \"Medium\",\r\n  \"type\": \"fruit\",\r\n  \"name\": \"Pomegranate\"\r\n}\r\n```\r\nSo the only thing that's changed is the color. Now, if you get the doc using sync gateway REST API, everything looks good:\r\n```\r\n{\r\n  \"_attachments\": {\r\n    \"photo\": {\r\n      \"content_type\": \"image/jpeg\",\r\n      \"digest\": \"sha1-ItXuFlL2CL3ERlRgM4Zc51mND94=\",\r\n      \"length\": 734666,\r\n      \"revpos\": 2,\r\n      \"stub\": true\r\n    }\r\n  },\r\n  \"_id\": \"bd87de36-9309-42b5-9e70-807848f90c7b\",\r\n  \"_rev\": \"3-2d3079680b2d359e35fd22d2bb1b53ab\",\r\n  \"color\": \"Red\",\r\n  \"size\": \"Medium\",\r\n  \"type\": \"fruit\",\r\n  \"name\": \"Pomegranate\"\r\n}\r\n```\r\nAnd the continuous sync kicks in and pulls the new revision, but now the current revision on the mobile device looks like this:\r\n```\r\n{\r\n  \"_id\": \"bd87de36-9309-42b5-9e70-807848f90c7b\",\r\n  \"_rev\": \"3-2d3079680b2d359e35fd22d2bb1b53ab\",\r\n  \"_revisions\": {\r\n    \"ids\": [\r\n      \"2d3079680b2d359e35fd22d2bb1b53ab\",\r\n      \"7ac57d1b2a5ab02ab396841cfff1d5b6\"\r\n    ],\r\n    \"start\": 3\r\n  },\r\n  \"color\": \"Red\",\r\n  \"size\": \"Medium\",\r\n  \"type\": \"fruit\",\r\n  \"name\": \"Pomegranate\"\r\n}\r\n```\r\n\r\nSo at this point, the attachments are gone and `doc.CurrentRevision.AttachmentNames` is empty. I can do `doc.CurrentRevision.Parent.AttachmentNames` and that rev still has its attachment, but I really need to know all the attachments just using the CurrentRevision.\r\n\r\nIf you repeat these steps, but instead of using continuous pull replication, just do a one shot pull each time a change is made on the web, the attachments sync down. Starting from a blank database on a mobile device also pulls the attachments down on the initial sync.\r\n\r\nI'm not sure what's going on here, but any insight would be appreciated."}}
{"actor":{"display_login":"ryanthompson0123"}}