# Unarchive can't handle empty archive files

**URL:** <https://forum.ansible.com/t/unarchive-cant-handle-empty-archive-files/29064>\
**Category:** Ansible Project\
**Created:** [November 19, 2018, 1:16pm UTC](https://forum.ansible.com/t/unarchive-cant-handle-empty-archive-files/29064 "2018-11-19T13:16:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![philippe.mxm](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@philippe.mxm](https://forum.ansible.com/u/philippe.mxm)\
**Post date:** [November 19, 2018, 1:16pm UTC](https://forum.ansible.com/t/unarchive-cant-handle-empty-archive-files/29064/1 "2018-11-19T13:16:26Z")

</div>

Hello,

When extracting an empty archive, the unarchive module exists with an error:

_“failed: [localhost] (item=/tmp/foo/bar.zip) =\> {“changed”: false, “item”: “/tmp/foo/bar.zip”, “msg”: “Failed to find handler for "/tmp/foo/bar.zip". Make sure the required command to extract the file is installed. Command "/bin/gtar" could not handle archive. Command "/bin/unzip" could not handle archive.”}”_

unzip exists with error code 1 and warning message “_warning [/tmp/foo/bar.zip]: zipfile is empty_”.

Ansible just stops there with a strange error message (took me quite some time to discover the cause).

I tried to handle it with “failed\_when” but it seems that you can’t register the command result in a var.  
The only way to prevent this I found is using “ignore\_errors” which I don’t want to use as I still want to stop if a “true” error happens.

Is there a proper way to handle this case ?

I know it’s not really a bug as unzip still exists with a value \>0 but I think there should be a in-application way to handle this.

ansible-playbook 2.6.4

python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

Thank you in advance.
