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/13 07:20:22 UTC

[GitHub] [airflow] tirkarthi opened a new issue, #22969: Invalid execution_date in query parameter will crash dag's durations page

tirkarthi opened a new issue, #22969:
URL: https://github.com/apache/airflow/issues/22969

   ### Apache Airflow version
   
   2.2.5 (latest released)
   
   ### What happened
   
   Invalid execution_date in query parameter will crash durations page since pendulum parsing exception is not handled in several views
   
   ### What you think should happen instead
   
   On `ParseError` the page should resort to some default value like in grid page or show an error flash message instead of crash.
   
   ### How to reproduce
   
   1. Visit a dag duration page with invalid date in URL : http://localhost:8080/dags/raise_exception/duration?days=30&root=&num_runs=25&base_date=2022-04-12+16%3A29%3A21%2B05%3A30er
   2. Stacktrace
   
   ```python
   Python version: 3.10.4
   Airflow version: 2.3.0.dev0
   Node: laptop
   -------------------------------------------------------------------------------
   Traceback (most recent call last):
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/pendulum/parsing/__init__.py", line 131, in _parse
       dt = parser.parse(
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 1368, in parse
       return DEFAULTPARSER.parse(timestr, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 643, in parse
       raise ParserError("Unknown string format: %s", timestr)
   dateutil.parser._parser.ParserError: Unknown string format: 2022-04-12 16:29:21+05:30er
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 2447, in wsgi_app
       response = self.full_dispatch_request()
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1952, in full_dispatch_request
       rv = self.handle_user_exception(e)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1821, in handle_user_exception
       reraise(exc_type, exc_value, tb)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/_compat.py", line 39, in reraise
       raise value
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1950, in full_dispatch_request
       rv = self.dispatch_request()
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py", line 1936, in dispatch_request
       return self.view_functions[rule.endpoint](**req.view_args)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/auth.py", line 40, in decorated
       return func(*args, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/decorators.py", line 80, in wrapper
       return f(*args, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/utils/session.py", line 71, in wrapper
       return func(*args, session=session, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/views.py", line 2870, in duration
       base_date = timezone.parse(base_date)
     File "/home/karthikeyan/stuff/python/airflow/airflow/utils/timezone.py", line 205, in parse
       return pendulum.parse(string, tz=timezone or TIMEZONE, strict=False)  # type: ignore
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/pendulum/parser.py", line 29, in parse
       return _parse(text, **options)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/pendulum/parser.py", line 45, in _parse
       parsed = base_parse(text, **options)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/pendulum/parsing/__init__.py", line 74, in parse
       return _normalize(_parse(text, **_options), **_options)
     File "/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/pendulum/parsing/__init__.py", line 135, in _parse
       raise ParserError("Invalid date string: {}".format(text))
   pendulum.parsing.exceptions.ParserError: Invalid date string: 2022-04-12 16:29:21+05:30er
   ```
   
   ### Operating System
   
   Ubuntu 20.04
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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

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


[GitHub] [airflow] uranusjr commented on issue #22969: Invalid execution_date in query parameter will crash dag's durations page

Posted by GitBox <gi...@apache.org>.
uranusjr commented on issue #22969:
URL: https://github.com/apache/airflow/issues/22969#issuecomment-1097665129

   FWIW this applies to all views accepting `excution_date`. Practically though, users are not supposed to manually write this parameter in, and Airflow never generates an invalid `execution_date` string, so all we need to do is to wrap the `timezone.parse()` call and return 400 if the input is invalid.


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


[GitHub] [airflow] uranusjr commented on issue #22969: Invalid execution_date crashes pages accepting the query parameter

Posted by GitBox <gi...@apache.org>.
uranusjr commented on issue #22969:
URL: https://github.com/apache/airflow/issues/22969#issuecomment-1097672924

   No need to return a JSON, just a `text/plain` with a simple message saying `execution_date` is invalid. This is not going to be seen except by the more experienced users anyway, and those who are adventurous enough should be able to understand what’s going on from the short response.


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


[GitHub] [airflow] tirkarthi commented on issue #22969: Invalid execution_date crashes pages accepting the query parameter

Posted by GitBox <gi...@apache.org>.
tirkarthi commented on issue #22969:
URL: https://github.com/apache/airflow/issues/22969#issuecomment-1097670928

   Agreed, it was a typo while copy pasting the link and I didn't expect a crash. Should we return a json response with error and status code as 400?


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


[GitHub] [airflow] bbovenzi closed issue #22969: Invalid execution_date crashes pages accepting the query parameter

Posted by GitBox <gi...@apache.org>.
bbovenzi closed issue #22969: Invalid execution_date crashes pages accepting the query parameter
URL: https://github.com/apache/airflow/issues/22969


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