-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow undefined max_age parameter in query_results endpoint #432
Conversation
@@ -450,7 +450,7 @@ def delete(self, visualization_id): | |||
class QueryResultListAPI(BaseResource): | |||
@require_permission('execute_query') | |||
def post(self): | |||
params = request.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we keep using request.json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to keep it, but the test case seems to serialize it into a format that can't be parsed by request.json
:
https://github.com/EverythingMe/redash/blob/master/tests/test_controllers.py#L33
Is it missing a header of some sort? I didn't have time to research. I just changed it to be consistent with the rest of the code in the controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I think there is a way to tell Flask to return json regardless of
the content type header. But keep it as is, I'll fix the test helper and
update it later.
On May 15, 2015 7:42 AM, "stanhu" notifications@github.com wrote:
In redash/controllers.py
#432 (comment):@@ -450,7 +450,7 @@ def delete(self, visualization_id):
class QueryResultListAPI(BaseResource):
@require_permission('execute_query')
def post(self):
params = request.json
I tried to keep it, but the test case seems to serialize it into a format
that can't be parsed by request.json:https://github.com/EverythingMe/redash/blob/master/tests/test_controllers.py#L33
Is it missing a header of some sort? I didn't have time to research. I
just changed it to be consistent with the rest of the code in the
controllers.—
Reply to this email directly or view it on GitHub
https://github.com/EverythingMe/redash/pull/432/files#r30384750.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I'm right:
http://stackoverflow.com/questions/20001229/how-to-get-posted-json-in-flask
I can fix this now if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Using get_json(force=True)
is not much shorter than json.loads(request.data)
. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-) true that.
I wonder if once I get to fix the test helper, we should keep the get_json(force=True)
(it's used in other places too, I think) or not ...
An Error 500 would be returned by the endpoint if you attempted to pass a query parameter to the dashboard since maxAge was undefined in JavaScript.
ca3ff90
to
690f832
Compare
Allow undefined max_age parameter in query_results endpoint
Thanks! |
An Error 500 would be returned by the endpoint if you attempt to
pass a query parameter to the dashboard since
maxAge
is undefined in the JavaScript code. This line of code was being executed:https://github.com/EverythingMe/redash/blob/74a5121be232a0a6002928c38c7290298370c7e0/rd_ui/app/scripts/services/resources.js#L454