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

Set strict to True when parsing dates in webserver views #33512

Merged
merged 5 commits into from
Aug 20, 2023

Conversation

hussein-awala
Copy link
Member

related: #33478
(I prefer to keep it open after merging this one)

This PR switch to strict datetime parsing to avoid rendering the views with unexpected dates:

>>> timezone = pendulum.tz.timezone("UTC")

>>> pendulum.parse("2023-08-18T21:23:10.518109+00:00", tz=timezone, strict=False)
DateTime(2023, 8, 18, 21, 23, 10, 518109, tzinfo=Timezone('+00:00'))

>>> pendulum.parse("2023-08-18T21:23:10.518109 00:00", tz=timezone, strict=False)
DateTime(2023, 8, 18, 0, 0, 0, 518109, tzinfo=Timezone('UTC'))

>>> pendulum.parse("2023-08-18T21:23:10.518109 00:00", tz=timezone, strict=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.9/site-packages/pendulum/parser.py", line 29, in parse
    return _parse(text, **options)
  File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.9/site-packages/pendulum/parser.py", line 45, in _parse
    parsed = base_parse(text, **options)
  File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.9/site-packages/pendulum/parsing/__init__.py", line 74, in parse
    return _normalize(_parse(text, **_options), **_options)
  File "/home/hussein.awala/anaconda3/envs/airflow-env/lib/python3.9/site-packages/pendulum/parsing/__init__.py", line 128, in _parse
    raise ParserError("Unable to parse string [{}]".format(text))
pendulum.parsing.exceptions.ParserError: Unable to parse string [2023-08-18T21:23:10.518109 00:00]

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk
Copy link
Member

potiuk commented Aug 19, 2023

I rebased it - but I think there will still be test failures.

airflow/utils/timezone.py Outdated Show resolved Hide resolved
airflow/www/views.py Outdated Show resolved Hide resolved
@potiuk potiuk merged commit 4390524 into apache:main Aug 20, 2023
42 checks passed
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.1 milestone Aug 27, 2023
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Aug 27, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 28, 2023
Co-authored-by: Tzu-ping Chung <[email protected]>

---------

Co-authored-by: Tzu-ping Chung <[email protected]>
(cherry picked from commit 4390524)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants