{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14304","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14304/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14304/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14304/events","html_url":"https://github.com/ansible/ansible/pull/14304","id":131325735,"number":14304,"title":"Emit warnings when safe_eval() raises a SyntaxError or other Exception","user":{"login":"dagwieers","id":388198,"avatar_url":"https://avatars.githubusercontent.com/u/388198?v=3","gravatar_id":"","url":"https://api.github.com/users/dagwieers","html_url":"https://github.com/dagwieers","followers_url":"https://api.github.com/users/dagwieers/followers","following_url":"https://api.github.com/users/dagwieers/following{/other_user}","gists_url":"https://api.github.com/users/dagwieers/gists{/gist_id}","starred_url":"https://api.github.com/users/dagwieers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagwieers/subscriptions","organizations_url":"https://api.github.com/users/dagwieers/orgs","repos_url":"https://api.github.com/users/dagwieers/repos","events_url":"https://api.github.com/users/dagwieers/events{/privacy}","received_events_url":"https://api.github.com/users/dagwieers/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bugfix_pull_request","name":"bugfix_pull_request","color":"ded270"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/5","html_url":"https://github.com/ansible/ansible/milestones/stable-2.0","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/5/labels","id":975800,"number":5,"title":"stable-2.0","description":"","creator":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":959,"state":"closed","created_at":"2015-02-11T19:43:06Z","updated_at":"2016-09-06T17:04:05Z","due_on":null,"closed_at":"2016-09-06T17:04:05Z"},"comments":6,"created_at":"2016-02-04T12:04:52Z","updated_at":"2016-09-08T15:58:10Z","closed_at":"2016-08-12T13:29:54Z","pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/14304","html_url":"https://github.com/ansible/ansible/pull/14304","diff_url":"https://github.com/ansible/ansible/pull/14304.diff","patch_url":"https://github.com/ansible/ansible/pull/14304.patch"},"body":"This change is related to reported issue #14291 and pull request #14293.\r\n\r\nWithout the fix from #14293, this change will emit a warning as shown below, on the following playbook:\r\n\r\n```yaml\r\n---\r\n- hosts: localhost\r\n  gather_facts: no\r\n  vars:\r\n    works:\r\n      key1: 'string'\r\n      key2: 1234\r\n    fails:\r\n      key1: 'string'\r\n      key2: 1234\r\n      key3: false\r\n  tasks:\r\n  - debug: msg={{ works | to_json }}\r\n  - debug: msg={{ fails | to_json }}\r\n```\r\n\r\nOn error, this results in a proper warning:\r\n\r\n```\r\n[dag@moria ansible.dag]$ ansible-playbook test49.yml\r\n\r\nPLAY ***************************************************************************\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": {\r\n        \"key1\": \"string\",\r\n        \"key2\": 1234\r\n    }\r\n}\r\n\r\nTASK [debug] *******************************************************************\r\n [WARNING]: Error in expression \"{\"key3\": false, \"key2\": 1234, \"key1\": \"string\"}\". (name 'false' is not defined)\r\n\r\nok: [localhost] => {\r\n    \"msg\": \"{\\\"key3\\\": false, \\\"key2\\\": 1234, \\\"key1\\\": \\\"string\\\"}\"\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=0\r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/245646155","html_url":"https://github.com/ansible/ansible/pull/14304#issuecomment-245646155","issue_url":"https://api.github.com/repos/ansible/ansible/issues/14304","id":245646155,"user":{"login":"dagwieers","id":388198,"avatar_url":"https://avatars.githubusercontent.com/u/388198?v=3","gravatar_id":"","url":"https://api.github.com/users/dagwieers","html_url":"https://github.com/dagwieers","followers_url":"https://api.github.com/users/dagwieers/followers","following_url":"https://api.github.com/users/dagwieers/following{/other_user}","gists_url":"https://api.github.com/users/dagwieers/gists{/gist_id}","starred_url":"https://api.github.com/users/dagwieers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagwieers/subscriptions","organizations_url":"https://api.github.com/users/dagwieers/orgs","repos_url":"https://api.github.com/users/dagwieers/repos","events_url":"https://api.github.com/users/dagwieers/events{/privacy}","received_events_url":"https://api.github.com/users/dagwieers/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T15:58:10Z","updated_at":"2016-09-08T15:58:10Z","body":"@brandond The warning is not related to YAML, but it is related to Jinja2 expression/statement evaluation. Since the statement is evaluated before some variables were known/evaluated/parsed, it causes a SyntaxError. In a subsequent (late) evaluation the syntax is considered fine because the variables are defined.\r\n\r\nFixed by PR #17462, however it would have been better if you opened a new issue for this."}}
{"actor":{"display_login":"dagwieers"}}