{"record":{"id":"35a3bb2b1d1a70c5","repo":"ansible/ansible","slug":"something-wrong-with-this-module-zip-file-should","errorCode":null,"errorMessage":"Something wrong with this module zip file: should not contain absolute paths","messagePattern":"Something wrong with this module zip file: should not contain absolute paths","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"lib/ansible/_internal/_ansiballz/_wrapper.py","lineNumber":193,"sourceCode":"        #\n        # You can now edit the source files to instrument the code or experiment with\n        # different parameter values.  When you're ready to run the code you've modified\n        # (instead of the code from the actual zipped module), use the execute subcommand like this::\n        #   $ /usr/bin/python /home/badger/.ansible/tmp/ansible-tmp-1461173013.93-9076457629738/ping execute\n\n        # Okay to use __file__ here because we're running from a kept file\n        basedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'debug_dir')\n        args_path = os.path.join(basedir, 'args')\n\n        if command == 'explode':\n            # transform the ZIPDATA into an exploded directory of code and then\n            # print the path to the code.  This is an easy way for people to look\n            # at the code on the remote machine for debugging it in that\n            # environment\n            z = zipfile.ZipFile(modlib_path)\n            for filename in z.namelist():\n                if filename.startswith('/'):\n                    raise Exception('Something wrong with this module zip file: should not contain absolute paths')\n\n                dest_filename = os.path.join(basedir, filename)\n                if dest_filename.endswith(os.path.sep) and not os.path.exists(dest_filename):\n                    os.makedirs(dest_filename)\n                else:\n                    directory = os.path.dirname(dest_filename)\n                    if not os.path.exists(directory):\n                        os.makedirs(directory)\n                    with open(dest_filename, 'wb') as writer:\n                        writer.write(z.read(filename))\n\n            # write the args file\n            with open(args_path, 'wb') as writer:\n                writer.write(json_params)\n\n            print('Module expanded into:')\n            print(basedir)\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/_internal/_ansiballz/_wrapper.py#L175-L211","documentation":"Raised by the ansiballz self-extracting wrapper when the 'explode' debug command finds a zip entry whose name starts with '/'. The module package must contain only relative paths; an absolute entry indicates a corrupted, hand-edited, or incompatible ansiballz payload.","triggerScenarios":"Running the wrapped module with 'explode' (debugging with ANSIBLE_KEEP_REMOTE_FILES=1) on a zip that contains an absolute-path entry — typically a wrapper built by a different/broken ansible-core version or a payload truncated in transfer.","commonSituations":"Mismatched controller vs target ansible-core versions where the wrapper template changed; a partially transferred module zip (network truncation); manually repacking an ansiballz file with absolute names.","solutions":["Ensure controller and target run compatible ansible-core versions — regenerate the module by rerunning the task rather than reusing old kept files","Delete stale remote tmp ansiballz files (find remote_tmp -name 'AnsiballZ_*' -delete) and retry with ANSIBLE_KEEP_REMOTE_FILES=1","Verify the zip locally: python -c \"import zipfile; print([n for n in zipfile.ZipFile('AnsiballZ_setup').namelist() if n.startswith('/')])\"","Check for transfer corruption: compare checksums of the module file on controller and target"],"exampleFix":"# before: stale/corrupt kept module\n# ansible -m ping host -e ANSIBLE_KEEP_REMOTE_FILES=1, then rerun explode on old file\n# after: clear kept files and regenerate\nfind \"${TMPDIR:-/tmp}/ansible\" -name 'AnsiballZ_*' -delete 2>/dev/null\nANSIBLE_KEEP_REMOTE_FILES=1 ansible host -m setup -a 'exploded_path=debug_dir'","handlingStrategy":"validation","validationCode":"import zipfile\nnames = zipfile.ZipFile(modlib_path).namelist()\nbad = [n for n in names if n.startswith('/')]\nif bad:\n    raise RuntimeError(f'corrupt ansiballz payload, absolute entries: {bad}')","typeGuard":null,"tryCatchPattern":"try:\n    wrapper_explode(payload)\nexcept Exception as e:\n    if 'absolute paths' in str(e):\n        # stale/corrupt module package: purge kept files and re-transfer\n        shutil.rmtree(debug_dir, ignore_errors=True)","preventionTips":["Clear AnsiballZ_* files in remote_tmp when regenerating modules","Keep controller and hosts on compatible ansible-core versions","Verify module checksums after transfer on flaky links"],"tags":["python","ansiballz","zip","packaging","corruption"],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}