{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-superset/pulls/comments/229840452","pull_request_review_id":170437899,"id":229840452,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTg0MDQ1Mg==","diff_hunk":"@@ -1109,29 +1116,27 @@ def get_samples(self, viz_obj):\n             'data': viz_obj.get_samples(),\n         })\n \n+    def check_datasource_permission(self, datasource, user=None):\n+        if not security_manager.datasource_access(datasource, user):\n+            return json_error_response(\n+                security_manager.get_datasource_access_error_msg(datasource),\n+                status=401,\n+                link=security_manager.get_datasource_access_link(datasource))\n+\n+    @handle_superset_exception\n     def generate_json(\n             self, datasource_type, datasource_id, form_data,\n             csv=False, query=False, force=False, results=False,\n             samples=False,\n     ):\n-        try:\n-            viz_obj = self.get_viz(\n-                datasource_type=datasource_type,\n-                datasource_id=datasource_id,\n-                form_data=form_data,\n-                force=force,\n-            )\n-        except Exception as e:\n-            logging.exception(e)\n-            return json_error_response(\n-                utils.error_msg_from_exception(e),\n-                stacktrace=traceback.format_exc())\n-\n-        if not security_manager.datasource_access(viz_obj.datasource, g.user):\n-            return json_error_response(\n-                security_manager.get_datasource_access_error_msg(viz_obj.datasource),\n-                status=404,\n-                link=security_manager.get_datasource_access_link(viz_obj.datasource))\n+        viz_obj = self.get_viz(\n+            query_obj=models.query_obj_backfill(form_data,\n+                                                datasource_id,\n+                                                datasource_type),\n+            form_data=form_data,\n+            force=force,\n+        )\n+        self.check_datasource_permission(viz_obj.datasource, g.user)","path":"superset/views/core.py","position":94,"original_position":94,"commit_id":"747089d0e970b7cff77a96d7e8844c537bd95662","original_commit_id":"747089d0e970b7cff77a96d7e8844c537bd95662","user":{"login":"mistercrunch","id":487433,"node_id":"MDQ6VXNlcjQ4NzQzMw==","avatar_url":"https://avatars1.githubusercontent.com/u/487433?v=4","gravatar_id":"","url":"https://api.github.com/users/mistercrunch","html_url":"https://github.com/mistercrunch","followers_url":"https://api.github.com/users/mistercrunch/followers","following_url":"https://api.github.com/users/mistercrunch/following{/other_user}","gists_url":"https://api.github.com/users/mistercrunch/gists{/gist_id}","starred_url":"https://api.github.com/users/mistercrunch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistercrunch/subscriptions","organizations_url":"https://api.github.com/users/mistercrunch/orgs","repos_url":"https://api.github.com/users/mistercrunch/repos","events_url":"https://api.github.com/users/mistercrunch/events{/privacy}","received_events_url":"https://api.github.com/users/mistercrunch/received_events","type":"User","site_admin":false},"body":"check_datasource_permission seems like it returns a json error message, and it looks like here it assumes that it raises.","created_at":"2018-10-31T19:41:24Z","updated_at":"2018-10-31T19:41:24Z","html_url":"https://github.com/apache/incubator-superset/pull/6220#discussion_r229840452","pull_request_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6220","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/comments/229840452"},"html":{"href":"https://github.com/apache/incubator-superset/pull/6220#discussion_r229840452"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6220"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-superset/pulls/6220","id":226719694,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NzE5Njk0","html_url":"https://github.com/apache/incubator-superset/pull/6220","diff_url":"https://github.com/apache/incubator-superset/pull/6220.diff","patch_url":"https://github.com/apache/incubator-superset/pull/6220.patch","issue_url":"https://api.github.com/repos/apache/incubator-superset/issues/6220","number":6220,"state":"open","locked":false,"title":"[SIP-5] Open a new /api/v1/query endpoint that takes query_obj","user":{"login":"xtinec","id":1521435,"node_id":"MDQ6VXNlcjE1MjE0MzU=","avatar_url":"https://avatars2.githubusercontent.com/u/1521435?v=4","gravatar_id":"","url":"https://api.github.com/users/xtinec","html_url":"https://github.com/xtinec","followers_url":"https://api.github.com/users/xtinec/followers","following_url":"https://api.github.com/users/xtinec/following{/other_user}","gists_url":"https://api.github.com/users/xtinec/gists{/gist_id}","starred_url":"https://api.github.com/users/xtinec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtinec/subscriptions","organizations_url":"https://api.github.com/users/xtinec/orgs","repos_url":"https://api.github.com/users/xtinec/repos","events_url":"https://api.github.com/users/xtinec/events{/privacy}","received_events_url":"https://api.github.com/users/xtinec/received_events","type":"User","site_admin":false},"body":"- Introduce a new handle_superset_exception decorator to avoid repeating the logic for catching SupersetExceptions\r\n- Create a query_obj_backfill method that takes form_data and constructs a query_obj that will be constructed in the client in the future. Use the backfill in explore_json.\r\n- Create a new /api/v1/query endpoint that takes query_obj only and returns the payload data. Note the query_obj is constructed in the client. The endpoint currently only handles query_obj for table view viz (we'll be adding support to new viz types as we go).\r\n- Unit test to verify the new endpoint for table view\r\n\r\n@mistercrunch @kristw @williaster @john-bodley @conglei ","created_at":"2018-10-29T21:28:20Z","updated_at":"2018-10-31T19:41:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52c06459941abfe8cdcb7ba702f184827dca8dec","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6220/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-superset/pulls/6220/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-superset/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-superset/issues/6220/comments","statuses_url":"https://api.github.com/repos/apache/incubator-superset/statuses/747089d0e970b7cff77a96d7e8844c537bd95662","head":{"label":"lyft:query-obj-end-point","ref":"query-obj-end-point","sha":"747089d0e970b7cff77a96d7e8844c537bd95662","user":{"login":"lyft","id":4269340,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjkzNDA=","avatar_url":"https://avatars2.githubusercontent.com/u/4269340?v=4","gravatar_id":"","url":"https://api.github.com/users/lyft","html_url":"https://github.com/lyft","followers_url":"https://api.github.com/users/lyft/followers","following_url":"https://api.github.com/users/lyft/following{/other_user}","gists_url":"https://api.github.com/users/lyft/gists{/gist_id}","starred_url":"https://api.github.com/users/lyft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyft/subscriptions","organizations_url":"https://api.github.com/users/lyft/orgs","repos_url":"https://api.github.com/users/lyft/repos","events_url":"https://api.github.com/users/lyft/events{/privacy}","received_events_url":"https://api.github.com/users/lyft/received_events","type":"Organization","site_admin":false},"repo":{"id":108907301,"node_id":"MDEwOlJlcG9zaXRvcnkxMDg5MDczMDE=","name":"incubator-superset","full_name":"lyft/incubator-superset","private":false,"owner":{"login":"lyft","id":4269340,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjkzNDA=","avatar_url":"https://avatars2.githubusercontent.com/u/4269340?v=4","gravatar_id":"","url":"https://api.github.com/users/lyft","html_url":"https://github.com/lyft","followers_url":"https://api.github.com/users/lyft/followers","following_url":"https://api.github.com/users/lyft/following{/other_user}","gists_url":"https://api.github.com/users/lyft/gists{/gist_id}","starred_url":"https://api.github.com/users/lyft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyft/subscriptions","organizations_url":"https://api.github.com/users/lyft/orgs","repos_url":"https://api.github.com/users/lyft/repos","events_url":"https://api.github.com/users/lyft/events{/privacy}","received_events_url":"https://api.github.com/users/lyft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/lyft/incubator-superset","description":"Apache Superset (incubating) is a modern, enterprise-ready business intelligence web application","fork":true,"url":"https://api.github.com/repos/lyft/incubator-superset","forks_url":"https://api.github.com/repos/lyft/incubator-superset/forks","keys_url":"https://api.github.com/repos/lyft/incubator-superset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lyft/incubator-superset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lyft/incubator-superset/teams","hooks_url":"https://api.github.com/repos/lyft/incubator-superset/hooks","issue_events_url":"https://api.github.com/repos/lyft/incubator-superset/issues/events{/number}","events_url":"https://api.github.com/repos/lyft/incubator-superset/events","assignees_url":"https://api.github.com/repos/lyft/incubator-superset/assignees{/user}","branches_url":"https://api.github.com/repos/lyft/incubator-superset/branches{/branch}","tags_url":"https://api.github.com/repos/lyft/incubator-superset/tags","blobs_url":"https://api.github.com/repos/lyft/incubator-superset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lyft/incubator-superset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lyft/incubator-superset/git/refs{/sha}","trees_url":"https://api.github.com/repos/lyft/incubator-superset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lyft/incubator-superset/statuses/{sha}","languages_url":"https://api.github.com/repos/lyft/incubator-superset/languages","stargazers_url":"https://api.github.com/repos/lyft/incubator-superset/stargazers","contributors_url":"https://api.github.com/repos/lyft/incubator-superset/contributors","subscribers_url":"https://api.github.com/repos/lyft/incubator-superset/subscribers","subscription_url":"https://api.github.com/repos/lyft/incubator-superset/subscription","commits_url":"https://api.github.com/repos/lyft/incubator-superset/commits{/sha}","git_commits_url":"https://api.github.com/repos/lyft/incubator-superset/git/commits{/sha}","comments_url":"https://api.github.com/repos/lyft/incubator-superset/comments{/number}","issue_comment_url":"https://api.github.com/repos/lyft/incubator-superset/issues/comments{/number}","contents_url":"https://api.github.com/repos/lyft/incubator-superset/contents/{+path}","compare_url":"https://api.github.com/repos/lyft/incubator-superset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lyft/incubator-superset/merges","archive_url":"https://api.github.com/repos/lyft/incubator-superset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lyft/incubator-superset/downloads","issues_url":"https://api.github.com/repos/lyft/incubator-superset/issues{/number}","pulls_url":"https://api.github.com/repos/lyft/incubator-superset/pulls{/number}","milestones_url":"https://api.github.com/repos/lyft/incubator-superset/milestones{/number}","notifications_url":"https://api.github.com/repos/lyft/incubator-superset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lyft/incubator-superset/labels{/name}","releases_url":"https://api.github.com/repos/lyft/incubator-superset/releases{/id}","deployments_url":"https://api.github.com/repos/lyft/incubator-superset/deployments","created_at":"2017-10-30T20:53:33Z","updated_at":"2018-08-31T06:47:09Z","pushed_at":"2018-10-31T18:29:21Z","git_url":"git://github.com/lyft/incubator-superset.git","ssh_url":"git@github.com:lyft/incubator-superset.git","clone_url":"https://github.com/lyft/incubator-superset.git","svn_url":"https://github.com/lyft/incubator-superset","homepage":"","size":97575,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":5,"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":1,"open_issues":5,"watchers":3,"default_branch":"lyft-master"}},"base":{"label":"apache:master","ref":"master","sha":"e1a3a680f4bc46dcdfd441fec287ac8ff18d06e4","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","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":39464018,"node_id":"MDEwOlJlcG9zaXRvcnkzOTQ2NDAxOA==","name":"incubator-superset","full_name":"apache/incubator-superset","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","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},"html_url":"https://github.com/apache/incubator-superset","description":"Apache Superset (incubating) is a modern, enterprise-ready business intelligence web application","fork":false,"url":"https://api.github.com/repos/apache/incubator-superset","forks_url":"https://api.github.com/repos/apache/incubator-superset/forks","keys_url":"https://api.github.com/repos/apache/incubator-superset/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-superset/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-superset/teams","hooks_url":"https://api.github.com/repos/apache/incubator-superset/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-superset/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-superset/events","assignees_url":"https://api.github.com/repos/apache/incubator-superset/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-superset/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-superset/tags","blobs_url":"https://api.github.com/repos/apache/incubator-superset/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-superset/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-superset/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-superset/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-superset/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-superset/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-superset/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-superset/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-superset/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-superset/subscription","commits_url":"https://api.github.com/repos/apache/incubator-superset/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-superset/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-superset/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-superset/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-superset/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-superset/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-superset/merges","archive_url":"https://api.github.com/repos/apache/incubator-superset/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-superset/downloads","issues_url":"https://api.github.com/repos/apache/incubator-superset/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-superset/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-superset/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-superset/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-superset/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-superset/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-superset/deployments","created_at":"2015-07-21T18:55:34Z","updated_at":"2018-10-31T16:34:36Z","pushed_at":"2018-10-31T19:35:57Z","git_url":"git://github.com/apache/incubator-superset.git","ssh_url":"git@github.com:apache/incubator-superset.git","clone_url":"https://github.com/apache/incubator-superset.git","svn_url":"https://github.com/apache/incubator-superset","homepage":"","size":94857,"stargazers_count":21622,"watchers_count":21622,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3852,"mirror_url":null,"archived":false,"open_issues_count":1042,"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":3852,"open_issues":1042,"watchers":21622,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6220"},"html":{"href":"https://github.com/apache/incubator-superset/pull/6220"},"issue":{"href":"https://api.github.com/repos/apache/incubator-superset/issues/6220"},"comments":{"href":"https://api.github.com/repos/apache/incubator-superset/issues/6220/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6220/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-superset/pulls/6220/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-superset/statuses/747089d0e970b7cff77a96d7e8844c537bd95662"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mistercrunch"}}