{"action":"created","comment":{"url":"https://api.github.com/repos/apache/couchdb/pulls/comments/138922582","pull_request_review_id":62784238,"id":138922582,"diff_hunk":"@@ -786,8 +794,35 @@ attachment_disk_term_test_() ->\n \n \n attachment_json_term_test_() ->\n-    %% We need to create a few variations including stubs and inline data.\n-    {\"JSON term tests\", []}.\n+    Props = [\n+        {<<\"content_type\">>, <<\"application/json\">>},\n+        {<<\"digest\">>, <<\"md5-QCNtWUNXV0UzJnEjMk92YUk1JA==\">>},\n+        {<<\"length\">>, 14},\n+        {<<\"revpos\">>, 1}\n+    ],\n+    PropsInline = [{<<\"data\">>, <<\"eyJhbnN3ZXIiOiA0Mn0=\">>}] ++ Props,\n+    Att = couch_att:new([\n+        {name, <<\"attachment.json\">>},\n+        {type, <<\"application/json\">>}\n+    ]),\n+    ResultStub = couch_att:new([\n+        {name, <<\"attachment.json\">>},\n+        {type, <<\"application/json\">>},\n+        {att_len, 14},\n+        {disk_len, 14},\n+        {md5, <<\"@#mYCWWE3&q#2OvaI5$\">>},\n+        {revpos, 1},\n+        {data, stub},\n+        {encoding, identity}\n+    ]),\n+    ResultFollows = ResultStub#att{data = follows},\n+    ResultInline = ResultStub#att{md5 = <<>>, data = <<\"{\\\"answer\\\": 42}\">>},\n+    {\"JSON term tests\", [\n+        ?_assertEqual(ResultStub, stub_from_json(Att, Props)),\n+        ?_assertEqual(ResultFollows, follow_from_json(Att, Props)),\n+        ?_assertEqual(ResultInline, inline_from_json(Att, PropsInline)),\n+        ?_assertThrow({bad_request, _}, inline_from_json(Att, Props))","path":"src/couch/src/couch_att.erl","position":72,"original_position":62,"commit_id":"27acb7ac86a41a9e2bc2f044c27738b364fb0a97","original_commit_id":"27acb7ac86a41a9e2bc2f044c27738b364fb0a97","user":{"login":"eiri","id":70542,"avatar_url":"https://avatars2.githubusercontent.com/u/70542?v=4","gravatar_id":"","url":"https://api.github.com/users/eiri","html_url":"https://github.com/eiri","followers_url":"https://api.github.com/users/eiri/followers","following_url":"https://api.github.com/users/eiri/following{/other_user}","gists_url":"https://api.github.com/users/eiri/gists{/gist_id}","starred_url":"https://api.github.com/users/eiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eiri/subscriptions","organizations_url":"https://api.github.com/users/eiri/orgs","repos_url":"https://api.github.com/users/eiri/repos","events_url":"https://api.github.com/users/eiri/events{/privacy}","received_events_url":"https://api.github.com/users/eiri/received_events","type":"User","site_admin":false},"body":"This covers the original's issue exception, but sure, I'll add another test.","created_at":"2017-09-14T15:10:57Z","updated_at":"2017-09-14T15:10:57Z","html_url":"https://github.com/apache/couchdb/pull/817#discussion_r138922582","pull_request_url":"https://api.github.com/repos/apache/couchdb/pulls/817","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/couchdb/pulls/comments/138922582"},"html":{"href":"https://github.com/apache/couchdb/pull/817#discussion_r138922582"},"pull_request":{"href":"https://api.github.com/repos/apache/couchdb/pulls/817"}},"in_reply_to_id":138920995},"pull_request":{"url":"https://api.github.com/repos/apache/couchdb/pulls/817","id":141097865,"html_url":"https://github.com/apache/couchdb/pull/817","diff_url":"https://github.com/apache/couchdb/pull/817.diff","patch_url":"https://github.com/apache/couchdb/pull/817.patch","issue_url":"https://api.github.com/repos/apache/couchdb/issues/817","number":817,"state":"open","locked":false,"title":"Don't crash on invalid inline attachments","user":{"login":"eiri","id":70542,"avatar_url":"https://avatars2.githubusercontent.com/u/70542?v=4","gravatar_id":"","url":"https://api.github.com/users/eiri","html_url":"https://github.com/eiri","followers_url":"https://api.github.com/users/eiri/followers","following_url":"https://api.github.com/users/eiri/following{/other_user}","gists_url":"https://api.github.com/users/eiri/gists{/gist_id}","starred_url":"https://api.github.com/users/eiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eiri/subscriptions","organizations_url":"https://api.github.com/users/eiri/orgs","repos_url":"https://api.github.com/users/eiri/repos","events_url":"https://api.github.com/users/eiri/events{/privacy}","received_events_url":"https://api.github.com/users/eiri/received_events","type":"User","site_admin":false},"body":"## Overview\r\n\r\nWe trust inline attachment to be base64 encoded, so in case it's not provided or invalidly encoded the upload request crashes with `function_clause`.\r\n\r\nThe change catches decode attempt and re-throws it as 400 error.\r\n\r\n## Testing recommendations\r\n\r\nStandard eunit and javascript tests should pass.\r\n\r\n## GitHub issue number\r\n\r\nFixes #784 \r\n\r\n## Checklist\r\n\r\n- [x] Code is written and works correctly;\r\n- [x] Changes are covered by tests;\r\n- [ ] Documentation reflects the changes;\r\n","created_at":"2017-09-14T14:57:43Z","updated_at":"2017-09-14T15:10:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cfbcc1b5b49d3d5ef89184e92dd625eac1e4bb8f","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/couchdb/pulls/817/commits","review_comments_url":"https://api.github.com/repos/apache/couchdb/pulls/817/comments","review_comment_url":"https://api.github.com/repos/apache/couchdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/couchdb/issues/817/comments","statuses_url":"https://api.github.com/repos/apache/couchdb/statuses/27acb7ac86a41a9e2bc2f044c27738b364fb0a97","head":{"label":"cloudant:issue-784-fix-invalid-base64-att-crash","ref":"issue-784-fix-invalid-base64-att-crash","sha":"27acb7ac86a41a9e2bc2f044c27738b364fb0a97","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars0.githubusercontent.com/u/44642?v=4","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":39005786,"name":"couchdb","full_name":"cloudant/couchdb","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars0.githubusercontent.com/u/44642?v=4","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/couchdb","description":"Mirror of Apache CouchDB","fork":true,"url":"https://api.github.com/repos/cloudant/couchdb","forks_url":"https://api.github.com/repos/cloudant/couchdb/forks","keys_url":"https://api.github.com/repos/cloudant/couchdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/couchdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/couchdb/teams","hooks_url":"https://api.github.com/repos/cloudant/couchdb/hooks","issue_events_url":"https://api.github.com/repos/cloudant/couchdb/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/couchdb/events","assignees_url":"https://api.github.com/repos/cloudant/couchdb/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/couchdb/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/couchdb/tags","blobs_url":"https://api.github.com/repos/cloudant/couchdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/couchdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/couchdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/couchdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/couchdb/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/couchdb/languages","stargazers_url":"https://api.github.com/repos/cloudant/couchdb/stargazers","contributors_url":"https://api.github.com/repos/cloudant/couchdb/contributors","subscribers_url":"https://api.github.com/repos/cloudant/couchdb/subscribers","subscription_url":"https://api.github.com/repos/cloudant/couchdb/subscription","commits_url":"https://api.github.com/repos/cloudant/couchdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/couchdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/couchdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/couchdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/couchdb/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/couchdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/couchdb/merges","archive_url":"https://api.github.com/repos/cloudant/couchdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/couchdb/downloads","issues_url":"https://api.github.com/repos/cloudant/couchdb/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/couchdb/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/couchdb/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/couchdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/couchdb/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/couchdb/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/couchdb/deployments","created_at":"2015-07-13T10:27:13Z","updated_at":"2017-07-20T19:29:35Z","pushed_at":"2017-09-14T14:52:40Z","git_url":"git://github.com/cloudant/couchdb.git","ssh_url":"git@github.com:cloudant/couchdb.git","clone_url":"https://github.com/cloudant/couchdb.git","svn_url":"https://github.com/cloudant/couchdb","homepage":null,"size":32883,"stargazers_count":5,"watchers_count":5,"language":"Erlang","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"ed6ec66972f268b6d6d86b55730e73cc4ab54ceb","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":206417,"name":"couchdb","full_name":"apache/couchdb","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/couchdb","description":"Apache CouchDB","fork":false,"url":"https://api.github.com/repos/apache/couchdb","forks_url":"https://api.github.com/repos/apache/couchdb/forks","keys_url":"https://api.github.com/repos/apache/couchdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/couchdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/couchdb/teams","hooks_url":"https://api.github.com/repos/apache/couchdb/hooks","issue_events_url":"https://api.github.com/repos/apache/couchdb/issues/events{/number}","events_url":"https://api.github.com/repos/apache/couchdb/events","assignees_url":"https://api.github.com/repos/apache/couchdb/assignees{/user}","branches_url":"https://api.github.com/repos/apache/couchdb/branches{/branch}","tags_url":"https://api.github.com/repos/apache/couchdb/tags","blobs_url":"https://api.github.com/repos/apache/couchdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/couchdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/couchdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/couchdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/couchdb/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/couchdb/languages","stargazers_url":"https://api.github.com/repos/apache/couchdb/stargazers","contributors_url":"https://api.github.com/repos/apache/couchdb/contributors","subscribers_url":"https://api.github.com/repos/apache/couchdb/subscribers","subscription_url":"https://api.github.com/repos/apache/couchdb/subscription","commits_url":"https://api.github.com/repos/apache/couchdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/couchdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/couchdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/couchdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/couchdb/contents/{+path}","compare_url":"https://api.github.com/repos/apache/couchdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/couchdb/merges","archive_url":"https://api.github.com/repos/apache/couchdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/couchdb/downloads","issues_url":"https://api.github.com/repos/apache/couchdb/issues{/number}","pulls_url":"https://api.github.com/repos/apache/couchdb/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/couchdb/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/couchdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/couchdb/labels{/name}","releases_url":"https://api.github.com/repos/apache/couchdb/releases{/id}","deployments_url":"https://api.github.com/repos/apache/couchdb/deployments","created_at":"2009-05-21T02:03:38Z","updated_at":"2017-09-14T14:24:14Z","pushed_at":"2017-09-14T14:57:43Z","git_url":"git://github.com/apache/couchdb.git","ssh_url":"git@github.com:apache/couchdb.git","clone_url":"https://github.com/apache/couchdb.git","svn_url":"https://github.com/apache/couchdb","homepage":"","size":26629,"stargazers_count":3212,"watchers_count":3212,"language":"Erlang","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":700,"mirror_url":null,"open_issues_count":63,"forks":700,"open_issues":63,"watchers":3212,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/couchdb/pulls/817"},"html":{"href":"https://github.com/apache/couchdb/pull/817"},"issue":{"href":"https://api.github.com/repos/apache/couchdb/issues/817"},"comments":{"href":"https://api.github.com/repos/apache/couchdb/issues/817/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/couchdb/pulls/817/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/couchdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/couchdb/pulls/817/commits"},"statuses":{"href":"https://api.github.com/repos/apache/couchdb/statuses/27acb7ac86a41a9e2bc2f044c27738b364fb0a97"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"eiri"}}