-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
[AIRFLOW-6728] Change various DAG info methods to POST #7364
Conversation
This also involves sending in the CSRF token.
The build failure looks like a timeout unrelated to the changes of this PR |
Codecov Report
@@ Coverage Diff @@
## master #7364 +/- ##
==========================================
+ Coverage 86.35% 86.35% +<.01%
==========================================
Files 871 871
Lines 40627 40636 +9
==========================================
+ Hits 35082 35091 +9
Misses 5545 5545
Continue to review full report at Codecov.
|
Have you actually encountered issues with the request body size? POST feels a bit weird here not very RESTy |
I brought this issue forward because the |
Rather than a JSON body more "resty" would be to have this be a "form post" -- i.e. application/x-www-form-urlencoded body. |
@mik-laj has a simiarl PR (but it keeps it as a GET which doesn't fix this problem) |
I can change the request to use a form post instead of JSON |
Here is my PR: https://github.com/apache/airflow/pulls/mik-laj |
I guess another option is doing multiple GET requests... |
I would like to point out that this endpoint belongs to the internal API so it didn't have to be pretty. This should work well. Only public APIs must be beautiful, standardized and backward compatible. |
Fair point :-) Cheers for fixing @madison-ookla and apologies for any breakage my original change caused. |
Thanks all for the feedback :) I would prefer to keep it as JSON just because it makes processing processing the request body a bit easier (rather than having to split a comma separated string). That said I don't do a lot of web-dev work so that practice may be commonplace. |
Although it looks like I could do |
There is the FormData API for doing the encoding if your interested https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects |
There's also a airflow/airflow/www/static/js/base.js Lines 75 to 103 in 9e150cf
|
And yes, using |
Gotcha, thanks @ashb. I'll move this over to a form POST then. |
That helper method won't accept multiple fields of the same name just yet, so you might have to extend that or use something else |
Since the request is done with |
I've converted the endpoints from JSON to form POST. It was easier than I thought! |
.post("dag_ids=" + (encoded_dag_ids.join(',')), dagStatsHandler); | ||
d3.json("{{ url_for('Airflow.task_stats') }}") | ||
.header("X-CSRFToken", "{{ csrf_token() }}") | ||
.post("dag_ids=" + (encoded_dag_ids.join(',')), taskStatsHandler); |
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.
Is this right? I would expect that this would post the encoded as a single parameter..
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.
We probably don't have to handle the encoding and building of forms ourselves:
var p = new URLSearchParams();
p.append("dag_id", "not+encoded.here");
p.append("dag_id", "second dag/id");
d3.json("/a").post(p)
And that sends this request:
POST /a HTTP/1.1
Host: 0.0.0.0:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0
Accept: application/json,*/*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 48
Origin: http://0.0.0.0:8080
Connection: keep-alive
Referer: http://0.0.0.0:8080/home
dag_id=not%2Bencoded.here&dag_id=second+dag%2Fid
Could you make this change @madison-ookla ?
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.
Sure, can do
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.
Done! I've tested this locally and it works 👍
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.
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.
Nice, looking good (and quite a short change in the end!)
Thanks! Any chance this can be backported to the v1.10.x branch? Edit: Nevermind, I see it's now part of the 1.10.10 fix version on Jira 🙂 |
If the number of dags was large and/or the length of the DAG ids were too large this would exceed the maximum possible query string limit. To work around that we have made these endpoints always make POST requests
@madison-ookla And included in 1.10.10 which was just released :) |
Thanks, very excited about this release! 😁 |
This PR changes the following DAG info methods to POST:
/dag_stats
/task_stats
/last_dagruns
/blocked
The reason for this is described in the JIRA ticket:
Here is a small DAG file I used to generate DAGs with excessively large names:
EXPAND FOR CODE
I was able to verify that the page loads correctly with the new changes. (BTW Breeze was extremely helpful for this 😀)
Issue link: AIRFLOW-6728
Make sure to mark the boxes below before creating PR: [x]
[AIRFLOW-NNNN]
. AIRFLOW-NNNN = JIRA ID** For document-only changes commit message can start with
[AIRFLOW-XXXX]
.In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.