{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10920","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10920/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10920/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10920/events","html_url":"https://github.com/ansible/ansible/issues/10920","id":73335545,"number":10920,"title":"Bug Report: Trying to resolve a dictionary key from an empty list","user":{"login":"Rylon","id":438452,"avatar_url":"https://avatars.githubusercontent.com/u/438452?v=3","gravatar_id":"","url":"https://api.github.com/users/Rylon","html_url":"https://github.com/Rylon","followers_url":"https://api.github.com/users/Rylon/followers","following_url":"https://api.github.com/users/Rylon/following{/other_user}","gists_url":"https://api.github.com/users/Rylon/gists{/gist_id}","starred_url":"https://api.github.com/users/Rylon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rylon/subscriptions","organizations_url":"https://api.github.com/users/Rylon/orgs","repos_url":"https://api.github.com/users/Rylon/repos","events_url":"https://api.github.com/users/Rylon/events{/privacy}","received_events_url":"https://api.github.com/users/Rylon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible/labels/P3","name":"P3","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-05T14:47:54Z","updated_at":"2015-07-14T09:52:36Z","closed_at":"2015-07-13T15:56:14Z","body":"**Issue Type**\r\nBug Report\r\n\r\n**Ansible Version**\r\nansible 1.9.1\r\nconfigured module search path = None\r\n\r\n**Environment**\r\nRunning from Mac OS X 10.10.3, managing Ubuntu 14.04 LTS.\r\n\r\n**Summary**\r\nUsing `with_items` and an empty list, the task fails if the list is expected to contain dictionaries, which you try to lookup by key.\r\n\r\n**Steps To Reproduce**\r\nConsider this task:\r\n\r\n```\r\n- name: Install custom Elasticsearch plugins\r\n  command:    /usr/share/elasticsearch/bin/plugin --install {{ item.name }} creates=\"/usr/share/elasticsearch/plugins/{{ item.installs_to }}\"\r\n  with_items: elasticsearch_plugins\r\n```\r\n\r\nWhen the `elasticsearch_plugins` variable is not defined, or is defined as an empty list (`[]`), I would expect the entire task to be skipped, however it looks like maybe Ansible is still trying to lookup the `name` key from `item`, which won't exist if the list is empty, and this results in the following failure:\r\n\r\n`fatal: [ubuntu_trusty] => One or more undefined variables: 'unicode object' has no attribute 'name'`\r\n\r\nWhen `elasticsearch_plugins` is defined as follows, this task works normally:\r\n\r\n```\r\nelasticsearch_plugins:\r\n  - name:        \"mobz/elasticsearch-head\"\r\n    installs_to: \"head\"\r\n```\r\n\r\n**Expected Results**\r\nWhen the `elasticsearch_plugins` variable is an empty list, this task should be skipped, without attempting to lookup `item.name` or `item.installs_to`.\r\n\r\n**Actual Results**\r\nThe task fails, with the following error:\r\n\r\n`fatal: [ubuntu_trusty] => One or more undefined variables: 'unicode object' has no attribute 'name'`"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/121185500","html_url":"https://github.com/ansible/ansible/issues/10920#issuecomment-121185500","issue_url":"https://api.github.com/repos/ansible/ansible/issues/10920","id":121185500,"user":{"login":"Rylon","id":438452,"avatar_url":"https://avatars.githubusercontent.com/u/438452?v=3","gravatar_id":"","url":"https://api.github.com/users/Rylon","html_url":"https://github.com/Rylon","followers_url":"https://api.github.com/users/Rylon/followers","following_url":"https://api.github.com/users/Rylon/following{/other_user}","gists_url":"https://api.github.com/users/Rylon/gists{/gist_id}","starred_url":"https://api.github.com/users/Rylon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rylon/subscriptions","organizations_url":"https://api.github.com/users/Rylon/orgs","repos_url":"https://api.github.com/users/Rylon/repos","events_url":"https://api.github.com/users/Rylon/events{/privacy}","received_events_url":"https://api.github.com/users/Rylon/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T09:52:36Z","updated_at":"2015-07-14T09:52:36Z","body":"@jimi-c thanks! I'm not 100% familiar with the development process, but what sort of time period are we talking about for going from current `devel` branch into a release?"}}