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

Returns false in case of an invalid datetime value in the datetime filter #61291

Open
wants to merge 2 commits into
base: devel
from

Conversation

@DinStamou
Copy link

commented Aug 25, 2019

SUMMARY

This commit adds a value check in the datetime filter.
In case of an invalid datetime value as an input it will return False to the user.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • Filter Plugin
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 25, 2019

The test ansible-test sanity --test pep8 [explain] failed with 3 errors:

lib/ansible/plugins/filter/core.py:104:7: E111 indentation is not a multiple of four
lib/ansible/plugins/filter/core.py:106:7: E111 indentation is not a multiple of four
lib/ansible/plugins/filter/core.py:108:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Aug 25, 2019

@DinStamou DinStamou changed the title Returns false in case of an invalid datetime value in the datetime fi… Returns false in case of an invalid datetime value in the datetime filter Aug 26, 2019

@bcoca bcoca removed the needs_triage label Aug 29, 2019

try:
return datetime.datetime.strptime(string, format)
except ValueError:
return False

This comment has been minimized.

Copy link
@bcoca

bcoca Aug 29, 2019

Member

this changes current default behaviour, I would reject as is, but allow a toggle to change the behaviour explicitly:

to_datetime(string, format, on_error=fail|ignore|etc)

@ansibot ansibot added the stale_ci label Sep 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.