-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
[sql_json] Ensuring the request body is JSON encoded #8256
[sql_json] Ensuring the request body is JSON encoded #8256
Conversation
0c41217
to
72c032a
Compare
endpoint: `/superset/sql_json/${window.location.search}`, | ||
postPayload, | ||
stringify: false, | ||
endpoint: '/superset/sql_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 saw this stringify: false
setting is from PR #5896. @williaster is there a special reason to turn off stringify?
if use stringify, do we still need parseMethod: 'text'
?
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.
don't we really want stringify: false
? I was under the impression that prevented us from sending up "null"
and "false"
versus null
and false
And parseMethod determines how we parse the response, not the request
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.
you will see we use post method in many, many places, only in sql lab added stringify: false
. I assume there must be reason to do extra...
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.
This is fine as it is, since we're setting body
instead of postPayload
, the stringify
param is no longer used
endpoint: `/superset/sql_json/${window.location.search}`, | ||
postPayload, | ||
stringify: false, | ||
endpoint: '/superset/sql_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.
don't we really want stringify: false
? I was under the impression that prevented us from sending up "null"
and "false"
versus null
and false
And parseMethod determines how we parse the response, not the request
#8163 👀 |
72c032a
to
61f4b5b
Compare
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.
lgtm, thanks for the fix!
endpoint: `/superset/sql_json/${window.location.search}`, | ||
postPayload, | ||
stringify: false, | ||
endpoint: '/superset/sql_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.
This is fine as it is, since we're setting body
instead of postPayload
, the stringify
param is no longer used
90c2678
to
19f0629
Compare
19f0629
to
bc4150f
Compare
Codecov Report
@@ Coverage Diff @@
## master #8256 +/- ##
=======================================
Coverage 65.66% 65.66%
=======================================
Files 481 481
Lines 23365 23365
Branches 2573 2573
=======================================
Hits 15342 15342
Misses 7885 7885
Partials 138 138
Continue to review full report at Codecov.
|
@@ -220,9 +220,9 @@ export function runQuery(query) { | |||
}; | |||
|
|||
return SupersetClient.post({ | |||
endpoint: `/superset/sql_json/${window.location.search}`, |
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.
CATEGORY
Choose one
SUMMARY
Somewhat of a yak-shaving PR as the intent was to fix an issue where Hive queries failed in SQL Lab if no schema was selected,
The error is coming from here in PyHive where it seems that the schema (database) is being defined via the
"null"
string as opposed toNone
.The root cause of this is in the front-end the
SupersetClient
has passing the data as form data (using themultipart/form-data
Content-Type header) which was then being processed in Flask viaresponse.form
. This meant everything was being encoded as strings, i.e., hence why we had logic like,and why
null
was being encoded as"null"
as opposed toNone
. The fix was to:response.json
to correctly process the response.GET
method tosql_json
.json
argument to Flask's testclient.post(...)
method which is actually a Python dictionary (ironically thedata
argument can be a JSON string) and removes the need to specify the Content-Type header (which is needed forresponse.json
otherwise we would need to useresponse.get_json(force=True)
which seems a little heavy handed).TEST PLAN
CI.
ADDITIONAL INFORMATION
REVIEWERS
to: @etr2460 @graceguo-supercat @serenajiang @williaster
cc: @mistercrunch @villebro