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 7 commits into
base: devel
Choose a base branch
from

Conversation

@DinStamou
Copy link

@DinStamou DinStamou 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
Copy link
Contributor

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

Loading

@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
lib/ansible/plugins/filter/core.py Outdated Show resolved Hide resolved
Loading
@ansibot
Copy link
Contributor

@ansibot ansibot commented Oct 5, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/plugins/filter/core.py:115:1: E302: expected 2 blank lines, found 1

click here for bot help

Loading

Copy link
Author

@DinStamou DinStamou left a comment

@bcoca can you check this change?

Loading

…lter without changing default behaviour

Fixed one missed blank line
@DinStamou
Copy link
Author

@DinStamou DinStamou commented Oct 28, 2019

@bcoca Any news on that, I think it is quite as requested as it is?

Loading

@DinStamou
Copy link
Author

@DinStamou DinStamou commented Dec 2, 2019

Any news on that?
@bcoca

Loading

lib/ansible/plugins/filter/core.py Show resolved Hide resolved
Loading
'''
if fail_on_error:
try:
return datetime.datetime.strptime(string, format)
Copy link
Member

@Akasurde Akasurde May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a changelog fragment. See this fragment as an example. Also, add testcase for this change.

Loading

Copy link
Author

@DinStamou DinStamou May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the review, I added your suggestion and the changelog fragment . What kind of test is required in this case, any specific tests you could suggest me to check?

Loading

DinStamou and others added 2 commits May 25, 2021
Suggested commit

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot
Copy link
Contributor

@ansibot ansibot commented May 25, 2021

@DinStamou this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

Loading

@ansibot
Copy link
Contributor

@ansibot ansibot commented May 25, 2021

The test ansible-test sanity --test pylint [explain] failed with 5 errors:

lib/ansible/plugins/filter/core.py:108:42: undefined-variable: Undefined variable 'string'
lib/ansible/plugins/filter/core.py:110:11: undefined-variable: Undefined variable 'fail_on_error'
lib/ansible/plugins/filter/core.py:111:76: undefined-variable: Undefined variable 'string'
lib/ansible/plugins/filter/core.py:112:33: undefined-variable: Undefined variable 'pathname'
lib/ansible/plugins/filter/core.py:611:24: undefined-variable: Undefined variable 'fileglob'

click here for bot help

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants