You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/24 21:37:39 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink

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 = url_for(f"Airflow.{view}")
   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:
users@infra.apache.org