This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ec8fab5d2a Fix bug introduced by replacing spaces by + in run_id 
(#36877)
ec8fab5d2a is described below

commit ec8fab5d2a0c1c30aa4f45f6d1a54d2610a6594e
Author: Ephraim Anierobi <splendidzig...@gmail.com>
AuthorDate: Thu Jan 18 23:53:14 2024 +0100

    Fix bug introduced by replacing spaces by + in run_id (#36877)
    
    While working on sanitizing the run_id(#32293), I replaced spaces with +
    which is not an ideal way to quote a URL. This led to issues when users
    use spaces in their DAG run_id.
    This commit fixes the issue by using urllib.parse.quote to properly quote
    the URL.
---
 airflow/www/views.py                      | 2 +-
 tests/www/views/test_views_trigger_dag.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/airflow/www/views.py b/airflow/www/views.py
index 2f085c795b..16776f72da 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1944,7 +1944,7 @@ class Airflow(AirflowBaseView):
     @provide_session
     def trigger(self, dag_id: str, session: Session = NEW_SESSION):
         """Triggers DAG Run."""
-        run_id = request.values.get("run_id", "").replace(" ", "+")
+        run_id = request.values.get("run_id", "")
         origin = get_safe_url(request.values.get("origin"))
         unpause = request.values.get("unpause")
         request_conf = request.values.get("conf")
diff --git a/tests/www/views/test_views_trigger_dag.py 
b/tests/www/views/test_views_trigger_dag.py
index 6471c092bd..7e89d29f5b 100644
--- a/tests/www/views/test_views_trigger_dag.py
+++ b/tests/www/views/test_views_trigger_dag.py
@@ -19,6 +19,7 @@ from __future__ import annotations
 
 import datetime
 import json
+from urllib.parse import quote
 
 import pytest
 
@@ -369,6 +370,7 @@ def 
test_trigger_dag_params_array_value_none_render(admin_client, dag_maker, ses
 def test_dag_run_id_pattern(session, admin_client, pattern, run_id, result):
     with conf_vars({("scheduler", "allowed_run_id_pattern"): pattern}):
         test_dag_id = "example_bash_operator"
+        run_id = quote(run_id)
         admin_client.post(f"dags/{test_dag_id}/trigger?run_id={run_id}", 
data={"conf": "{}"})
         run = session.query(DagRun).filter(DagRun.dag_id == 
test_dag_id).first()
         if result:

Reply via email to