Skip to content
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

Merged
merged 1 commit into from
May 15, 2015

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented May 15, 2015

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

@@ -450,7 +450,7 @@ def delete(self, visualization_id):
class QueryResultListAPI(BaseResource):
@require_permission('execute_query')
def post(self):
params = request.json
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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). :)

Copy link
Member

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.
@stanhu stanhu force-pushed the allow-undefined-max-age branch from ca3ff90 to 690f832 Compare May 15, 2015 05:00
arikfr added a commit that referenced this pull request May 15, 2015
Allow undefined max_age parameter in query_results endpoint
@arikfr arikfr merged commit 105971c into getredash:master May 15, 2015
@arikfr
Copy link
Member

arikfr commented May 15, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants