{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/41795627","id":41795627,"diff_hunk":"@@ -26,28 +52,33 @@ def json_api_exception_handler(exc, context):\n                 }\n             ])\n         elif isinstance(message, dict):\n-            for error_key, error_description in message.iteritems():\n-                if error_key in top_level_error_keys:\n-                    errors.append({error_key: error_description})\n-                elif error_key in resource_object_identifiers:\n-                    if isinstance(error_description, basestring):\n-                        error_description = [error_description]\n-                    errors.extend([{'source': {'pointer': '/data/' + error_key}, 'detail': reason} for reason in error_description])\n-                elif error_key == 'attributes':\n-                    if isinstance(error_description, list):\n-                        errors.extend([{'source': {'pointer': '/data/' + error_key}, 'detail': reason} for reason in error_description])\n-                else:\n-                    if isinstance(error_description, basestring):\n-                        error_description = [error_description]\n-                    errors.extend([{'source': {'pointer': '/data/attributes/' + error_key}, 'detail': reason} for reason in error_description])\n-\n+            errors.extend(dict_error_formatting(message))\n         else:\n             if isinstance(message, basestring):\n                 message = [message]\n-            errors.extend([{'detail': error} for error in message])\n+            for error in message:\n+                if isinstance(error, dict):\n+                    errors.extend(dict_error_formatting(error))\n+                else:\n+                    errors.append({'detail': error})\n \n         response.data = {'errors': errors}\n \n+        # For bulk operations: If 400 error, return request data with response.\n+        if response.status_code == 400 and \"non_field_errors\" not in message:\n+            request_data = context['request'].data\n+            if isinstance(request_data, list):\n+                formatted_request_data = []\n+                for data in request_data:\n+                    formatted = {'type': data.pop('type')}\n+                    id = data.pop('id')\n+                    if id is not None:\n+                        formatted['id'] = id\n+                    formatted['attributes'] = data\n+                    formatted_request_data.append(formatted)\n+\n+                response.data['meta'] = {'request_data': formatted_request_data}","path":"api/base/exceptions.py","position":92,"original_position":92,"commit_id":"3781fa2d1d904989da5a8e7db9635e1cc1280d58","original_commit_id":"3781fa2d1d904989da5a8e7db9635e1cc1280d58","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":"Is this something that is included in the spec somewhere? If not, what is the rationale for this?","created_at":"2015-10-12T20:07:49Z","updated_at":"2015-10-12T20:07:49Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4353#discussion_r41795627","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/41795627"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4353#discussion_r41795627"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353","id":45944067,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4353","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/4353.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/4353.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4353","number":4353,"state":"open","locked":false,"title":"[Ready to Review] API Bulk Modification","user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"body":"# Purpose\r\n\r\nAllows bulk modifications of nodes, contributors, children, and node-links.  You can:\r\n- Create/update/delete multiple nodes /v2/nodes/\r\n- Create/update/delete multiple contributors /v2/nodes/{node_id}/contributors/\r\n- Create multiple children /v2/nodes/{node_id}/children/\r\n- Create/delete multiple node-links /v2/nodes/{node_id}/node_links/\r\n\r\nIssue: https://openscience.atlassian.net/browse/OSF-4234\r\n\r\nComplies with json-api bulk extension: \r\nhttp://jsonapi.org/extensions/bulk/\r\n\r\n**Note:** `application/vnd.api+json; supported-ext=\"bulk\"` is **not** in Content-Type header.  The negotiation mechanism is very likely to change http://discuss.jsonapi.org/t/bulk-extension-how-much-is-expected-to-change-prior-to-v1-1/121\r\n\r\n# Changes\r\n1) To **create** multiple nodes, send POST request to /v2/nodes/ with array of resource objects.  Each object needs a `type` and `attributes` field.\r\n```\r\nPOST /v2/nodes/\r\n        {\r\n            \"data\": [{\r\n                \"type\": \"nodes\",\r\n                \"attributes\": {\r\n                    \"title\": \"New title\", \r\n                    \"category\": \"project\"\r\n                }\r\n            },\r\n                {\r\n                \"type\": \"nodes\",\r\n                \"attributes\": {\r\n                    \"title\": \"Better title\", \r\n                    \"category\": \"project\"\r\n                }\r\n            }]\r\n        }\r\n\r\n```\r\n2) To **update** multiple nodes, sent PUT or PATCH request to /v2/nodes/ with array of resource objects. Each object must have `type` and `id`.\r\n```\r\nPATCH /v2/nodes/\r\n        {\r\n            \"data\": [{\r\n                \"id\": \"fdxfr\",\r\n                \"type\": \"nodes\",\r\n                \"attributes\": {\r\n                    \"title\": \"New title\", \r\n                    \"category\": \"instrumentation\"\r\n                }\r\n            },\r\n                {\r\n                \"id\": \"dsfsa\",\r\n                \"type\": \"nodes\",\r\n                \"attributes\": {\r\n                    \"title\": \"Better title\", \r\n                    \"category\": \"hypothesis\"\r\n                }\r\n            }]\r\n        }\r\n```\r\n3) To **delete** multiple nodes, send DELETE request to /v2/nodes/ with array of resource objects. Each object must have `type` and `id`.\r\n```\r\nDELETE /v2/nodes/\r\n\r\n        {\r\n            \"data\": [{\r\n                \"id\": \"fdxfr\",\r\n                \"type\": \"nodes\",\r\n            },\r\n                {\r\n                \"id\": \"dsfsa\",\r\n                \"type\": \"nodes\",\r\n            }]\r\n        }\r\n```","created_at":"2015-09-24T20:14:44Z","updated_at":"2015-10-12T20:07:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e0c0d5e9f3db9c2fea7ce601e8183fa9fadc0ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4353/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3781fa2d1d904989da5a8e7db9635e1cc1280d58","head":{"label":"pattisdr:feature/API_bulk_operations_nodes","ref":"feature/API_bulk_operations_nodes","sha":"3781fa2d1d904989da5a8e7db9635e1cc1280d58","user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"repo":{"id":35900874,"name":"osf.io","full_name":"pattisdr/osf.io","owner":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pattisdr/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/pattisdr/osf.io","forks_url":"https://api.github.com/repos/pattisdr/osf.io/forks","keys_url":"https://api.github.com/repos/pattisdr/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pattisdr/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pattisdr/osf.io/teams","hooks_url":"https://api.github.com/repos/pattisdr/osf.io/hooks","issue_events_url":"https://api.github.com/repos/pattisdr/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/pattisdr/osf.io/events","assignees_url":"https://api.github.com/repos/pattisdr/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/pattisdr/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/pattisdr/osf.io/tags","blobs_url":"https://api.github.com/repos/pattisdr/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pattisdr/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pattisdr/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/pattisdr/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pattisdr/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/pattisdr/osf.io/languages","stargazers_url":"https://api.github.com/repos/pattisdr/osf.io/stargazers","contributors_url":"https://api.github.com/repos/pattisdr/osf.io/contributors","subscribers_url":"https://api.github.com/repos/pattisdr/osf.io/subscribers","subscription_url":"https://api.github.com/repos/pattisdr/osf.io/subscription","commits_url":"https://api.github.com/repos/pattisdr/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/pattisdr/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/pattisdr/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/pattisdr/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/pattisdr/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/pattisdr/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pattisdr/osf.io/merges","archive_url":"https://api.github.com/repos/pattisdr/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pattisdr/osf.io/downloads","issues_url":"https://api.github.com/repos/pattisdr/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/pattisdr/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/pattisdr/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/pattisdr/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pattisdr/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/pattisdr/osf.io/releases{/id}","created_at":"2015-05-19T18:33:09Z","updated_at":"2015-05-19T18:33:13Z","pushed_at":"2015-10-12T17:12:05Z","git_url":"git://github.com/pattisdr/osf.io.git","ssh_url":"git@github.com:pattisdr/osf.io.git","clone_url":"https://github.com/pattisdr/osf.io.git","svn_url":"https://github.com/pattisdr/osf.io","homepage":"http://osf.io","size":104182,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"68c1b1523219937cab1277b6f51f998f28f5d406","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","created_at":"2013-05-21T15:53:37Z","updated_at":"2015-10-11T20:46:09Z","pushed_at":"2015-10-12T20:01:29Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"http://osf.io","size":233927,"stargazers_count":144,"watchers_count":144,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"open_issues_count":426,"forks":125,"open_issues":426,"watchers":144,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/4353"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4353"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4353/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4353/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3781fa2d1d904989da5a8e7db9635e1cc1280d58"}}}}