uranusjr commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r600891025
##########
File path: airflow/utils/helpers.py
##########
@@ -213,4 +213,4 @@ def build_airflow_url_with_query(query: Dict[str, Any]) ->
str:
'http://0.0.0.0:8000/base/graph?dag_id=my-task&root=&execution_date=2020-10-27T10%3A59%3A25.615587
"""
view = conf.get('webserver', 'dag_default_view').lower()
- return f"/{view}?{parse.urlencode(query)}"
+ return url_for(f'Airflow.{view}', **query)
Review comment:
Kwrags of `url_for` are by default used for endpoint variable arguments
(e.g. `/foo/{var}`), and only unrecognised key-values are appended as a query
string. This works now since (I think) none of Airflow’s endpoints currently
take any arguments, but could introduce subtle bugs in the future. Something
like this is probably better for maintenance down the road.
```python
url = flask.url_for(f"Airflow.{view}")
return f"{url}?{urllib.parse.urlencode(query)}"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]