{"action":"created","comment":{"url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments/241862457","pull_request_review_id":185240692,"id":241862457,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTg2MjQ1Nw==","diff_hunk":"@@ -800,18 +800,26 @@ func (bh *blipHandler) handleRev(rq *blip.Message) error {\n \t\t\treturn base.HTTPErrorf(http.StatusBadRequest, \"Error getting delta body: %s\", err)\n \t\t}\n \n-\t\tdeltaSrcBody, err := bh.db.GetRev(docID, deltaSrcRevID, true, nil)\n+\t\t//  TODO: Doing a GetRevCopy here duplicates some rev cache retrieval effort, since deltaRevSrc is always\n+\t\t//        going to be the current rev (no conflicts), and PutExistingRev will need to retrieve the\n+\t\t//        current rev over again.  Should push this handling down PutExistingRev and use the version\n+\t\t//        returned via callback in WriteUpdate, but blocked by moving attachment metadata to a rev property first\n+\t\t//        (otherwise we don't have information needed to do downloadOrVerifyAttachments below prior to PutExistingRev)\n+\n+\t\t// Note: Using GetRevCopy here, and not direct rev cache retrieval, because it's still necessary to apply access check\n+\t\t//       while retrieving deltaSrcRevID.  Couchbase Lite replication guarantees client has access to deltaSrcRevID,\n+\t\t//       due to no-conflict write restriction, but we still need to enforce security here to prevent leaking data about previous\n+\t\t//       revisions to malicious actors (in the scenario where that user has write but not read access).\n+\t\tdeltaSrcBody, err := bh.db.GetRevCopy(docID, deltaSrcRevID, false, nil, db.BodyDeepCopy)\n \t\tif err != nil {\n \t\t\treturn base.HTTPErrorf(http.StatusNotFound, \"Can't fetch doc for deltaSrc=%s %v\", deltaSrcRevID, err)\n \t\t}\n \n-\t\t// TODO: need to add deep-copy support to revcache so deltaSrcBody doesn't get mutated\n-\t\tvar deltaSrcBodyCopy map[string]interface{}\n-\t\tif err := base.DeepCopyInefficient(&deltaSrcBodyCopy, deltaSrcBody); err != nil {\n-\t\t\treturn base.HTTPErrorf(http.StatusInternalServerError, \"Error copying deltaSrcBody: %s\", err)\n-\t\t}\n+\t\t// Strip out _id, _rev properties inserted by GetRevCopy\n+\t\tdelete(deltaSrcBody, db.BodyId)","path":"rest/blip_sync.go","position":26,"original_position":26,"commit_id":"dcca1ac3bbc81907499f71f33241151e19cce8ef","original_commit_id":"dcca1ac3bbc81907499f71f33241151e19cce8ef","user":{"login":"tleyden","id":296876,"node_id":"MDQ6VXNlcjI5Njg3Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/296876?v=4","gravatar_id":"","url":"https://api.github.com/users/tleyden","html_url":"https://github.com/tleyden","followers_url":"https://api.github.com/users/tleyden/followers","following_url":"https://api.github.com/users/tleyden/following{/other_user}","gists_url":"https://api.github.com/users/tleyden/gists{/gist_id}","starred_url":"https://api.github.com/users/tleyden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleyden/subscriptions","organizations_url":"https://api.github.com/users/tleyden/orgs","repos_url":"https://api.github.com/users/tleyden/repos","events_url":"https://api.github.com/users/tleyden/events{/privacy}","received_events_url":"https://api.github.com/users/tleyden/received_events","type":"User","site_admin":false},"body":"I wonder if this belongs in `GetRevCopy`?  It could be controlled by an extra param like `StripMetadataProps`\r\n\r\nSince the param list is already long, it could take a `RevCopyOptions` struct as a parameter, and `StripMetadataProps` and `db.BodyDeepCopy` would be fields of that struct.\r\n\r\n\r\n","created_at":"2018-12-14T19:20:18Z","updated_at":"2018-12-14T19:21:09Z","html_url":"https://github.com/couchbase/sync_gateway/pull/3863#discussion_r241862457","pull_request_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments/241862457"},"html":{"href":"https://github.com/couchbase/sync_gateway/pull/3863#discussion_r241862457"},"pull_request":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863"}}},"pull_request":{"url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863","id":238588091,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4NTg4MDkx","html_url":"https://github.com/couchbase/sync_gateway/pull/3863","diff_url":"https://github.com/couchbase/sync_gateway/pull/3863.diff","patch_url":"https://github.com/couchbase/sync_gateway/pull/3863.patch","issue_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3863","number":3863,"state":"open","locked":false,"title":"CBG-166 Specify body copy policy on rev cache retrieval","user":{"login":"adamcfraser","id":8866453,"node_id":"MDQ6VXNlcjg4NjY0NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/8866453?v=4","gravatar_id":"","url":"https://api.github.com/users/adamcfraser","html_url":"https://github.com/adamcfraser","followers_url":"https://api.github.com/users/adamcfraser/followers","following_url":"https://api.github.com/users/adamcfraser/following{/other_user}","gists_url":"https://api.github.com/users/adamcfraser/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcfraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcfraser/subscriptions","organizations_url":"https://api.github.com/users/adamcfraser/orgs","repos_url":"https://api.github.com/users/adamcfraser/repos","events_url":"https://api.github.com/users/adamcfraser/events{/privacy}","received_events_url":"https://api.github.com/users/adamcfraser/received_events","type":"User","site_admin":false},"body":"Avoids duplicate copy during delta processing (shallow, then deep).\r\n","created_at":"2018-12-14T01:53:47Z","updated_at":"2018-12-14T19:21:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70f20e47d8f798335a4babba352af06a86c62b92","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":107354377,"node_id":"MDU6TGFiZWwxMDczNTQzNzc=","url":"https://api.github.com/repos/couchbase/sync_gateway/labels/in%20progress","name":"in progress","color":"ededed","default":false},{"id":109316238,"node_id":"MDU6TGFiZWwxMDkzMTYyMzg=","url":"https://api.github.com/repos/couchbase/sync_gateway/labels/review","name":"review","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863/commits","review_comments_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863/comments","review_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3863/comments","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/dcca1ac3bbc81907499f71f33241151e19cce8ef","head":{"label":"couchbase:feature/CBG-166","ref":"feature/CBG-166","sha":"dcca1ac3bbc81907499f71f33241151e19cce8ef","user":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"repo":{"id":6082996,"node_id":"MDEwOlJlcG9zaXRvcnk2MDgyOTk2","name":"sync_gateway","full_name":"couchbase/sync_gateway","private":false,"owner":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/couchbase/sync_gateway","description":"Manages access and synchronization between Couchbase Lite and Couchbase Server","fork":false,"url":"https://api.github.com/repos/couchbase/sync_gateway","forks_url":"https://api.github.com/repos/couchbase/sync_gateway/forks","keys_url":"https://api.github.com/repos/couchbase/sync_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/couchbase/sync_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/couchbase/sync_gateway/teams","hooks_url":"https://api.github.com/repos/couchbase/sync_gateway/hooks","issue_events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/couchbase/sync_gateway/events","assignees_url":"https://api.github.com/repos/couchbase/sync_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/couchbase/sync_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/couchbase/sync_gateway/tags","blobs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/couchbase/sync_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/couchbase/sync_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/couchbase/sync_gateway/languages","stargazers_url":"https://api.github.com/repos/couchbase/sync_gateway/stargazers","contributors_url":"https://api.github.com/repos/couchbase/sync_gateway/contributors","subscribers_url":"https://api.github.com/repos/couchbase/sync_gateway/subscribers","subscription_url":"https://api.github.com/repos/couchbase/sync_gateway/subscription","commits_url":"https://api.github.com/repos/couchbase/sync_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/couchbase/sync_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/couchbase/sync_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/couchbase/sync_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/couchbase/sync_gateway/merges","archive_url":"https://api.github.com/repos/couchbase/sync_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/couchbase/sync_gateway/downloads","issues_url":"https://api.github.com/repos/couchbase/sync_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/couchbase/sync_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/couchbase/sync_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/labels{/name}","releases_url":"https://api.github.com/repos/couchbase/sync_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/couchbase/sync_gateway/deployments","created_at":"2012-10-04T22:25:43Z","updated_at":"2018-12-14T18:28:59Z","pushed_at":"2018-12-14T18:28:56Z","git_url":"git://github.com/couchbase/sync_gateway.git","ssh_url":"git@github.com:couchbase/sync_gateway.git","clone_url":"https://github.com/couchbase/sync_gateway.git","svn_url":"https://github.com/couchbase/sync_gateway","homepage":"https://www.couchbase.com/products/sync-gateway","size":30377,"stargazers_count":389,"watchers_count":389,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":124,"mirror_url":null,"archived":false,"open_issues_count":351,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":124,"open_issues":351,"watchers":389,"default_branch":"master"}},"base":{"label":"couchbase:master","ref":"master","sha":"62808792b946fa00685ac07543b85ac40c6e8d93","user":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"repo":{"id":6082996,"node_id":"MDEwOlJlcG9zaXRvcnk2MDgyOTk2","name":"sync_gateway","full_name":"couchbase/sync_gateway","private":false,"owner":{"login":"couchbase","id":605755,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNTc1NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/605755?v=4","gravatar_id":"","url":"https://api.github.com/users/couchbase","html_url":"https://github.com/couchbase","followers_url":"https://api.github.com/users/couchbase/followers","following_url":"https://api.github.com/users/couchbase/following{/other_user}","gists_url":"https://api.github.com/users/couchbase/gists{/gist_id}","starred_url":"https://api.github.com/users/couchbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/couchbase/subscriptions","organizations_url":"https://api.github.com/users/couchbase/orgs","repos_url":"https://api.github.com/users/couchbase/repos","events_url":"https://api.github.com/users/couchbase/events{/privacy}","received_events_url":"https://api.github.com/users/couchbase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/couchbase/sync_gateway","description":"Manages access and synchronization between Couchbase Lite and Couchbase Server","fork":false,"url":"https://api.github.com/repos/couchbase/sync_gateway","forks_url":"https://api.github.com/repos/couchbase/sync_gateway/forks","keys_url":"https://api.github.com/repos/couchbase/sync_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/couchbase/sync_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/couchbase/sync_gateway/teams","hooks_url":"https://api.github.com/repos/couchbase/sync_gateway/hooks","issue_events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/couchbase/sync_gateway/events","assignees_url":"https://api.github.com/repos/couchbase/sync_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/couchbase/sync_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/couchbase/sync_gateway/tags","blobs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/couchbase/sync_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/couchbase/sync_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/couchbase/sync_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/couchbase/sync_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/couchbase/sync_gateway/languages","stargazers_url":"https://api.github.com/repos/couchbase/sync_gateway/stargazers","contributors_url":"https://api.github.com/repos/couchbase/sync_gateway/contributors","subscribers_url":"https://api.github.com/repos/couchbase/sync_gateway/subscribers","subscription_url":"https://api.github.com/repos/couchbase/sync_gateway/subscription","commits_url":"https://api.github.com/repos/couchbase/sync_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/couchbase/sync_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/couchbase/sync_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/couchbase/sync_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/couchbase/sync_gateway/merges","archive_url":"https://api.github.com/repos/couchbase/sync_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/couchbase/sync_gateway/downloads","issues_url":"https://api.github.com/repos/couchbase/sync_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/couchbase/sync_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/couchbase/sync_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/couchbase/sync_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/labels{/name}","releases_url":"https://api.github.com/repos/couchbase/sync_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/couchbase/sync_gateway/deployments","created_at":"2012-10-04T22:25:43Z","updated_at":"2018-12-14T18:28:59Z","pushed_at":"2018-12-14T18:28:56Z","git_url":"git://github.com/couchbase/sync_gateway.git","ssh_url":"git@github.com:couchbase/sync_gateway.git","clone_url":"https://github.com/couchbase/sync_gateway.git","svn_url":"https://github.com/couchbase/sync_gateway","homepage":"https://www.couchbase.com/products/sync-gateway","size":30377,"stargazers_count":389,"watchers_count":389,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":124,"mirror_url":null,"archived":false,"open_issues_count":351,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":124,"open_issues":351,"watchers":389,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863"},"html":{"href":"https://github.com/couchbase/sync_gateway/pull/3863"},"issue":{"href":"https://api.github.com/repos/couchbase/sync_gateway/issues/3863"},"comments":{"href":"https://api.github.com/repos/couchbase/sync_gateway/issues/3863/comments"},"review_comments":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863/comments"},"review_comment":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/couchbase/sync_gateway/pulls/3863/commits"},"statuses":{"href":"https://api.github.com/repos/couchbase/sync_gateway/statuses/dcca1ac3bbc81907499f71f33241151e19cce8ef"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"tleyden"}}