ansible/ansible · error · UnarchiveError
ZIP info perm format incorrect, %s
Error message
ZIP info perm format incorrect, %s
What it means
When unarchive must shell out to 'unzip -Z (zipinfo)' to inspect permissions, it validates each entry's permission string against a 9-char rwx regex (ZIP_FILE_MODE_RE). If the listing line yields a perm field that is not 9 rwx-style characters, it raises this UnarchiveError naming the offending permstr.
Source
Thrown at lib/ansible/modules/unarchive.py:605
elif permstr == 'rwx---':
permstr = 'rwxrwxrwx'
else:
permstr = 'rw-rw-rw-'
file_umask = umask
elif len(permstr) == 7:
if permstr == 'rwxa---':
permstr = 'rwxrwxrwx'
else:
permstr = 'rw-rw-rw-'
file_umask = umask
elif 'bsd' in systemtype.lower():
file_umask = umask
else:
file_umask = 0
# Test string conformity
if len(permstr) != 9 or not ZIP_FILE_MODE_RE.match(permstr):
raise UnarchiveError('ZIP info perm format incorrect, %s' % permstr)
# DEBUG
# err += "%s%s %10d %s\n" % (ztype, permstr, size, path)
b_dest = os.path.join(self.b_dest, to_bytes(path, errors='surrogate_or_strict'))
try:
st = os.lstat(b_dest)
except Exception:
change = True
self.includes.append(path)
err += 'Path %s is missing\n' % path
diff += '>%s++++++.?? %s\n' % (ftype, path)
continue
# Compare file types
if ftype == 'd' and not stat.S_ISDIR(st.st_mode):
change = True
self.includes.append(path)View on GitHub (pinned to 9cf16a4aca)
Solutions
- Run unzip -Z /path/archive.zip on the host and compare the permissions column to standard rwxrwxrwx format
- Upgrade/downgrade unzip to the standard Info-ZIP release the parser expects
- Set explicit permissions in the task (mode:) or use the Python zipfile path (keep unzip out) by ensuring python3-zipfile is usable
- Recreate the zip with standard permissions (e.g. zip -X) to normalize the fields
Example fix
# before
- ansible.builtin.unarchive:
src: /tmp/app.zip
dest: /opt/app
remote_src: true
# UnarchiveError: ZIP info perm format incorrect, rwxa---
# after: normalize archive on the build side
# zip -X -r app.zip app/ (drops extra attribute fields)
- ansible.builtin.unarchive:
src: /tmp/app.zip
dest: /opt/app
remote_src: true
mode: '0755' Defensive patterns
Strategy: validation
Validate before calling
import re
ZIP_FILE_MODE_RE = re.compile(r'^[rwxstT-]{9}$')
def permstr_ok(permstr):
return len(permstr) == 9 and bool(ZIP_FILE_MODE_RE.match(permstr)) Try / catch
try:
handler.canonicalize_permissions(permstr)
except UnarchiveError as e:
module.fail_json(msg=str(e), hint='unzip -Z output unexpected; standardize unzip version or rebuild zip') Prevention
- Pin a standard Info-ZIP unzip in target images
- Create zips with zip -X to normalize attributes
- Set explicit mode: in unarchive tasks to bypass zipinfo parsing
When it happens
Trigger: unzip -Z output on a non-GNU/BSD system whose locale or unzip build formats the permissions field differently; exotic zip entries with unusual attribute encodings; parsing drift after an unzip version change.
Common situations: BusyBox unzip variants; unzip 6.3+ with different column output; archives with entries created by Info-ZIP flags the parser does not expect.
Related errors
- Neither python zipfile nor unzip can read %s
- Unable to list files in the archive
- Cannot change ownership of %s to %s, as user %s
- Unable to read the contents of {path!r}.
- Unable to list files in the archive: %s
AI-assisted analysis of ansible/ansible@9cf16a4aca (2026-08-15).
Data as JSON: /api/errors/85e58399db08522a.
Report an issue: GitHub.