{"action":"created","comment":{"url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/comments/165466194","pull_request_review_id":93411593,"id":165466194,"diff_hunk":"@@ -219,31 +219,64 @@ def create_bulk_download_job(self, json_request, file_name):\n                                                 download_job.json_request))\n         return download_job\n \n-    def post(self, request):\n-        \"\"\"Return all budget function/subfunction titles matching the provided search text\"\"\"\n-        json_request = request.data\n-\n+    def validate_request(self, json_request):\n+        # Initial Argument Checking\n         for required_param in ['award_levels', 'filters']:\n             if required_param not in json_request:\n                 raise InvalidParameterException('{} parameter not provided'.format(required_param))\n-        if json_request['filters'] == {}:\n+        if not isinstance(json_request['award_levels'], list):\n+            raise InvalidParameterException('Award levels parameter not provided as a list')\n+        elif len(json_request['award_levels']) == 0:\n+            raise InvalidParameterException('At least one award level is required.')\n+        if not isinstance(json_request['filters'], dict):\n+            raise InvalidParameterException('Filters parameter not provided as a dict')\n+        elif len(json_request['filters']) == 0:\n             raise InvalidParameterException('At least one filter is required.')\n+        filters = json_request['filters']\n         json_request['columns'] = json_request.get('columns', [])\n         json_request['file_format'] = json_request.get('file_format', 'csv')\n \n         fields_defaults = {\n             'award_types': list(award_type_mappings.keys()),\n-            'agency': None,\n-            'sub_agency': None,\n+            'agency': '',\n+            'sub_agency': '',\n+            'date_range': {},\n             'date_type': 'action_date',\n-            'keyword': None\n+            'keyword': ''\n         }\n         for field in fields_defaults:\n-            json_request['filters'][field] = json_request['filters'].get(field, fields_defaults[field])\n-        json_request['filters']['date_range'] = json_request['filters'].get('date_range', {})\n-        json_request['filters']['date_range']['start_date'] = (json_request['filters']['date_range']\n-                                                               .get('start_date', None))\n-        json_request['filters']['date_range']['end_date'] = json_request['filters']['date_range'].get('end_date', None)\n+            filters[field] = filters.get(field, fields_defaults[field])\n+            if not isinstance(filters[field], type(fields_defaults[field])):\n+                type_name = type(fields_defaults[field]).__name__\n+                raise InvalidParameterException('{} parameter not provided as a {}'.format(field, type_name))\n+        filters['date_range']['start_date'] = filters['date_range'].get('start_date', '')","path":"usaspending_api/bulk_download/v2/views.py","position":56,"original_position":56,"commit_id":"56b1004e3304bbca5cc0500154248e92168d8950","original_commit_id":"56b1004e3304bbca5cc0500154248e92168d8950","user":{"login":"nmonga91","id":16244012,"avatar_url":"https://avatars2.githubusercontent.com/u/16244012?v=4","gravatar_id":"","url":"https://api.github.com/users/nmonga91","html_url":"https://github.com/nmonga91","followers_url":"https://api.github.com/users/nmonga91/followers","following_url":"https://api.github.com/users/nmonga91/following{/other_user}","gists_url":"https://api.github.com/users/nmonga91/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonga91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonga91/subscriptions","organizations_url":"https://api.github.com/users/nmonga91/orgs","repos_url":"https://api.github.com/users/nmonga91/repos","events_url":"https://api.github.com/users/nmonga91/events{/privacy}","received_events_url":"https://api.github.com/users/nmonga91/received_events","type":"User","site_admin":false},"body":"is it intentional to overwrite what's in `filters` for the `date_range`? For the date_range key, we should also enforce they provide _something_. It shouldn't be empty since that could fail the checks below for the day difference calculation.\r\n\r\nEmpty strings would also pass this check `if not isinstance(filters['date_range'][date_range_param], str)` which we probably don't want it to.","created_at":"2018-02-01T19:41:22Z","updated_at":"2018-02-01T19:41:44Z","html_url":"https://github.com/fedspendingtransparency/usaspending-api/pull/926#discussion_r165466194","pull_request_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/comments/165466194"},"html":{"href":"https://github.com/fedspendingtransparency/usaspending-api/pull/926#discussion_r165466194"},"pull_request":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926"}}},"pull_request":{"url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926","id":166627496,"html_url":"https://github.com/fedspendingtransparency/usaspending-api/pull/926","diff_url":"https://github.com/fedspendingtransparency/usaspending-api/pull/926.diff","patch_url":"https://github.com/fedspendingtransparency/usaspending-api/pull/926.patch","issue_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/926","number":926,"state":"open","locked":false,"title":"Bulk Download Fixes (filters, deleting on failures)","user":{"login":"dpb-bah","id":29313570,"avatar_url":"https://avatars2.githubusercontent.com/u/29313570?v=4","gravatar_id":"","url":"https://api.github.com/users/dpb-bah","html_url":"https://github.com/dpb-bah","followers_url":"https://api.github.com/users/dpb-bah/followers","following_url":"https://api.github.com/users/dpb-bah/following{/other_user}","gists_url":"https://api.github.com/users/dpb-bah/gists{/gist_id}","starred_url":"https://api.github.com/users/dpb-bah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpb-bah/subscriptions","organizations_url":"https://api.github.com/users/dpb-bah/orgs","repos_url":"https://api.github.com/users/dpb-bah/repos","events_url":"https://api.github.com/users/dpb-bah/events{/privacy}","received_events_url":"https://api.github.com/users/dpb-bah/received_events","type":"User","site_admin":false},"body":"- Refactored filters to catch cases when arguments are of the wrong type\r\n- Included `date_range` filter constraint to 365 days\r\n- Bulk Download deletes messages upon failure","created_at":"2018-02-01T19:19:16Z","updated_at":"2018-02-01T19:41:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bed7b4ed48af3fe756bf30889402965457f3dc56","assignee":{"login":"nmonga91","id":16244012,"avatar_url":"https://avatars2.githubusercontent.com/u/16244012?v=4","gravatar_id":"","url":"https://api.github.com/users/nmonga91","html_url":"https://github.com/nmonga91","followers_url":"https://api.github.com/users/nmonga91/followers","following_url":"https://api.github.com/users/nmonga91/following{/other_user}","gists_url":"https://api.github.com/users/nmonga91/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonga91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonga91/subscriptions","organizations_url":"https://api.github.com/users/nmonga91/orgs","repos_url":"https://api.github.com/users/nmonga91/repos","events_url":"https://api.github.com/users/nmonga91/events{/privacy}","received_events_url":"https://api.github.com/users/nmonga91/received_events","type":"User","site_admin":false},"assignees":[{"login":"nmonga91","id":16244012,"avatar_url":"https://avatars2.githubusercontent.com/u/16244012?v=4","gravatar_id":"","url":"https://api.github.com/users/nmonga91","html_url":"https://github.com/nmonga91","followers_url":"https://api.github.com/users/nmonga91/followers","following_url":"https://api.github.com/users/nmonga91/following{/other_user}","gists_url":"https://api.github.com/users/nmonga91/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonga91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonga91/subscriptions","organizations_url":"https://api.github.com/users/nmonga91/orgs","repos_url":"https://api.github.com/users/nmonga91/repos","events_url":"https://api.github.com/users/nmonga91/events{/privacy}","received_events_url":"https://api.github.com/users/nmonga91/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926/commits","review_comments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926/comments","review_comment_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/926/comments","statuses_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/statuses/56b1004e3304bbca5cc0500154248e92168d8950","head":{"label":"fedspendingtransparency:bugfix-bd-filters-failures","ref":"bugfix-bd-filters-failures","sha":"56b1004e3304bbca5cc0500154248e92168d8950","user":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars0.githubusercontent.com/u/8397762?v=4","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"repo":{"id":65394827,"name":"usaspending-api","full_name":"fedspendingtransparency/usaspending-api","owner":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars0.githubusercontent.com/u/8397762?v=4","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fedspendingtransparency/usaspending-api","description":"An RESTful API for U.S. federal spending data.","fork":false,"url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api","forks_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/forks","keys_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/teams","hooks_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/hooks","issue_events_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/events{/number}","events_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/events","assignees_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/assignees{/user}","branches_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/branches{/branch}","tags_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/tags","blobs_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/statuses/{sha}","languages_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/languages","stargazers_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/stargazers","contributors_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/contributors","subscribers_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/subscribers","subscription_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/subscription","commits_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/contents/{+path}","compare_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/merges","archive_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/downloads","issues_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues{/number}","pulls_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls{/number}","milestones_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/milestones{/number}","notifications_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/labels{/name}","releases_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/releases{/id}","deployments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/deployments","created_at":"2016-08-10T15:39:45Z","updated_at":"2018-01-29T17:30:32Z","pushed_at":"2018-02-01T19:30:33Z","git_url":"git://github.com/fedspendingtransparency/usaspending-api.git","ssh_url":"git@github.com:fedspendingtransparency/usaspending-api.git","clone_url":"https://github.com/fedspendingtransparency/usaspending-api.git","svn_url":"https://github.com/fedspendingtransparency/usaspending-api","homepage":"","size":47725,"stargazers_count":52,"watchers_count":52,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":14,"open_issues":9,"watchers":52,"default_branch":"dev"}},"base":{"label":"fedspendingtransparency:dev","ref":"dev","sha":"7b65ad0a4f9e1ad659ea1f6e9b55f99c5e38bdd6","user":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars0.githubusercontent.com/u/8397762?v=4","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"repo":{"id":65394827,"name":"usaspending-api","full_name":"fedspendingtransparency/usaspending-api","owner":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars0.githubusercontent.com/u/8397762?v=4","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fedspendingtransparency/usaspending-api","description":"An RESTful API for U.S. federal spending data.","fork":false,"url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api","forks_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/forks","keys_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/teams","hooks_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/hooks","issue_events_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/events{/number}","events_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/events","assignees_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/assignees{/user}","branches_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/branches{/branch}","tags_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/tags","blobs_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/statuses/{sha}","languages_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/languages","stargazers_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/stargazers","contributors_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/contributors","subscribers_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/subscribers","subscription_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/subscription","commits_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/contents/{+path}","compare_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/merges","archive_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/downloads","issues_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues{/number}","pulls_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls{/number}","milestones_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/milestones{/number}","notifications_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/labels{/name}","releases_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/releases{/id}","deployments_url":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/deployments","created_at":"2016-08-10T15:39:45Z","updated_at":"2018-01-29T17:30:32Z","pushed_at":"2018-02-01T19:30:33Z","git_url":"git://github.com/fedspendingtransparency/usaspending-api.git","ssh_url":"git@github.com:fedspendingtransparency/usaspending-api.git","clone_url":"https://github.com/fedspendingtransparency/usaspending-api.git","svn_url":"https://github.com/fedspendingtransparency/usaspending-api","homepage":"","size":47725,"stargazers_count":52,"watchers_count":52,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":14,"open_issues":9,"watchers":52,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926"},"html":{"href":"https://github.com/fedspendingtransparency/usaspending-api/pull/926"},"issue":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/926"},"comments":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/issues/926/comments"},"review_comments":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926/comments"},"review_comment":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/pulls/926/commits"},"statuses":{"href":"https://api.github.com/repos/fedspendingtransparency/usaspending-api/statuses/56b1004e3304bbca5cc0500154248e92168d8950"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nmonga91"}}