{"record":{"id":"f80f515c38548706","repo":"hashicorp/packer","slug":"error-creating-zip-s","errorCode":null,"errorMessage":"Error creating zip: %s","messagePattern":"Error creating zip: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"post-processor/compress/post-processor.go","lineNumber":221,"sourceCode":"\n\tcompression := p.config.Algorithm\n\tif compression == \"\" {\n\t\tcompression = \"no compression\"\n\t}\n\n\t// Build an archive, if we're supposed to do that.\n\tswitch p.config.Archive {\n\tcase \"tar\":\n\t\tui.Say(fmt.Sprintf(\"Tarring %s with %s\", target, compression))\n\t\terr = createTarArchive(artifact.Files(), output)\n\t\tif err != nil {\n\t\t\treturn nil, false, false, fmt.Errorf(\"Error creating tar: %s\", err)\n\t\t}\n\tcase \"zip\":\n\t\tui.Say(fmt.Sprintf(\"Zipping %s\", target))\n\t\terr = createZipArchive(artifact.Files(), output)\n\t\tif err != nil {\n\t\t\treturn nil, false, false, fmt.Errorf(\"Error creating zip: %s\", err)\n\t\t}\n\tdefault:\n\t\t// Filename indicates no tarball (just compress) so we'll do an io.Copy\n\t\t// into our compressor.\n\t\tif len(artifact.Files()) != 1 {\n\t\t\treturn nil, false, false, fmt.Errorf(\n\t\t\t\t\"Can only have 1 input file when not using tar/zip. Found %d \"+\n\t\t\t\t\t\"files: %v\", len(artifact.Files()), artifact.Files())\n\t\t}\n\t\tarchiveFile := artifact.Files()[0]\n\t\tui.Say(fmt.Sprintf(\"Archiving %s with %s\", archiveFile, compression))\n\n\t\tsource, err := os.Open(archiveFile)\n\t\tif err != nil {\n\t\t\treturn nil, false, false, fmt.Errorf(\n\t\t\t\t\"Failed to open source file %s for reading: %s\",\n\t\t\t\tarchiveFile, err)\n\t\t}","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/post-processor/compress/post-processor.go#L203-L239","documentation":"The zip archiving step inside Packer's compress post-processor failed. createZipArchive writes each artifact file into a zip stream layered on the compression writer; any open/stat/header/write error is wrapped as 'Error creating zip'. The build stops and the output archive is unusable.","triggerScenarios":"PostProcess with archive set to \"zip\" and createZipArchive returning an error: artifact file unreadable, zip header creation fails, or a write to the zip writer errors (disk full, broken output file).","commonSituations":"Disk exhaustion while zipping large images; artifact files with permissions the Packer process cannot read; output path on a filesystem that hit a quota or I/O error mid-write.","solutions":["Inspect the wrapped inner error for the exact failing file or write condition","Ensure artifact files are readable by the Packer process","Free disk space or move output to a larger volume","Retry the build to rule out a transient I/O error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: verify artifact files are readable and disk has headroom\nfor _, f := range artifact.Files() {\n    if _, err := os.Open(f); err != nil { return err }\n}\n// approximate required space = sum of input sizes\nvar need int64\nfor _, f := range artifact.Files() { if fi, _ := os.Stat(f); fi != nil { need += fi.Size() } }","typeGuard":null,"tryCatchPattern":"// Go: branch on the wrapped error text\nif err != nil {\n    if strings.Contains(err.Error(), \"Error creating zip\") {\n        // inspect inner cause (ENOSPC, permission) and remediate\n    }\n    return err\n}","preventionTips":["Monitor output volume free space during builds","Verify permissions on builder-generated files","Retry transient I/O failures before failing the whole pipeline","Keep post-processors on the same local filesystem as outputs"],"tags":["packer","post-processor","zip","archive"],"backgroundTag":"archive-creation-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}