# ignore -has no attribute

**URL:** <https://forum.ansible.com/t/ignore-has-no-attribute/32037>\
**Category:** Ansible Project\
**Created:** [January 23, 2020, 10:18am UTC](https://forum.ansible.com/t/ignore-has-no-attribute/32037 "2020-01-23T10:18:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jegansignup](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jegansignup](https://forum.ansible.com/u/jegansignup)\
**Post date:** [January 23, 2020, 10:18am UTC](https://forum.ansible.com/t/ignore-has-no-attribute/32037/1 "2020-01-23T10:18:55Z")

</div>

Hello Team,

I am parsing register value using debug and using when condition to print particular matching value. While doing that am getting below error. some of the register value doesn’t have “volume\_attachments” variable due to that the when condition is failing. I want to ignore this error how can I do it. Could you please help me on this. Thanks in advance.

fatal: [localhost]: FAILED! =\> {“msg”: “The conditional check ‘item.volume\_attachments | length == 0’ failed. The error was: error while evaluating conditional (item.volume\_attachments | length == 0): ‘dict object’ has no attribute ‘volume\_attachments’\n\nThe error appears to be in ‘/var/lib/home/s’: line 33, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n”}

Regards,  
Jegan A

---

<div class="post-metadata">

**Author:** ![Martin\_Krizek](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Martin\_Krizek](https://forum.ansible.com/u/Martin_Krizek)\
**Post date:** [January 23, 2020, 10:58am UTC](https://forum.ansible.com/t/ignore-has-no-attribute/32037/2 "2020-01-23T10:58:22Z")

</div>

Use "default" filter:  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#defaulting-undefined-variables](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#defaulting-undefined-variables)

Example:  
- hosts: localhost  
&nbsp;&nbsp;gather\_facts: no  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;d:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: value  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ d.missing\_attr | default('default\_value') }}"
