Skip to content
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

Audit Log records View should not contain link if dag_id is None #13619

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/www/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def dag_link(attr):
dag_id = attr.get('dag_id')
execution_date = attr.get('execution_date')
url = url_for('Airflow.graph', dag_id=dag_id, execution_date=execution_date)
return Markup('<a href="{}">{}</a>').format(url, dag_id) # noqa
return Markup('<a href="{}">{}</a>').format(url, dag_id) if dag_id else Markup('None') # noqa


def dag_run_link(attr):
Expand Down
10 changes: 10 additions & 0 deletions tests/www/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def test_dag_link(self):
self.assertIn('%3Ca%261%3E', html)
self.assertNotIn('<a&1>', html)

def test_dag_link_when_dag_is_none(self):
"""Test that when there is no dag_id, dag_link does not contain hyperlink"""
from airflow.www.app import cached_app

with cached_app(testing=True).test_request_context():
html = str(utils.dag_link({}))

self.assertIn('None', html)
self.assertNotIn('<a href=', html)

def test_dag_run_link(self):
from airflow.www.app import cached_app

Expand Down