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 2022/04/22 07:00:54 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #23161: Handle invalid date parsing in webserver views.

uranusjr commented on code in PR #23161:
URL: https://github.com/apache/airflow/pull/23161#discussion_r855824222


##########
airflow/www/views.py:
##########
@@ -186,13 +186,19 @@ def get_date_time_num_runs_dag_runs_form_data(www_request, session, dag):
     """Get Execution Data, Base Date & Number of runs from a Request"""
     date_time = www_request.args.get('execution_date')
     if date_time:
-        date_time = timezone.parse(date_time)
+        try:
+            date_time = timezone.parse(date_time)
+        except ParserError:
+            return {"error": "Invalid execution_date"}

Review Comment:
   Instead of returning a dict and checking it outside, it’d be better to simply catch and handle `ParserError` outside this function.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org