{"record":{"id":"e1ab7cacc9e6de96","repo":"hashicorp/packer","slug":"errwronginputcount","errorCode":"ErrWrongInputCount","errorMessage":"Can only have 1 input file when not using tar/zip","messagePattern":"Can only have 1 input file when not using tar/zip","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"post-processor/compress/post-processor.go","lineNumber":37,"sourceCode":"\t\"github.com/biogo/hts/bgzf\"\n\t\"github.com/dsnet/compress/bzip2\"\n\t\"github.com/hashicorp/hcl/v2/hcldec\"\n\t\"github.com/hashicorp/packer-plugin-sdk/common\"\n\tpackersdk \"github.com/hashicorp/packer-plugin-sdk/packer\"\n\t\"github.com/hashicorp/packer-plugin-sdk/template/config\"\n\t\"github.com/hashicorp/packer-plugin-sdk/template/interpolate\"\n\t\"github.com/klauspost/pgzip\"\n\t\"github.com/pierrec/lz4/v4\"\n\t\"github.com/ulikunitz/xz\"\n)\n\nvar (\n\t// ErrInvalidCompressionLevel is returned when the compression level passed\n\t// to gzip is not in the expected range. See compress/flate for details.\n\tErrInvalidCompressionLevel = fmt.Errorf(\n\t\t\"Invalid compression level. Expected an integer from -1 to 9.\")\n\n\tErrWrongInputCount = fmt.Errorf(\n\t\t\"Can only have 1 input file when not using tar/zip\")\n\n\tfilenamePattern = regexp.MustCompile(`(?:\\.([a-z0-9]+))`)\n)\n\ntype Config struct {\n\tcommon.PackerConfig `mapstructure:\",squash\"`\n\n\t// Fields from config file\n\tOutputPath       string `mapstructure:\"output\"`\n\tFormat           string `mapstructure:\"format\"`\n\tCompressionLevel int    `mapstructure:\"compression_level\"`\n\n\t// Derived fields\n\tArchive   string\n\tAlgorithm string\n\n\tctx interpolate.Context","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/post-processor/compress/post-processor.go#L19-L55","documentation":"ErrWrongInputCount is a sentinel error indicating the compress post-processor received more than one input artifact file while configured to write a single compressed file (no tar/zip). Without an archive format there is no way to bundle multiple files into one output.","triggerScenarios":"PostProcess is given an artifact whose Files() list has more than one entry while algorithm output mode is a plain single-file compression (CompressionAlgorithm not tar/zip).","commonSituations":"Chaining the compress post-processor after a builder that produced multiple files (e.g. several disk images); using compress after an artifact that aggregates multiple outputs; forgetting to enable keep_input_artifact/tar when multiple artifacts are expected.","solutions":["Set compress to tar or zip mode so multiple inputs are archived (configure output with .tar/.zip extension or set the archive option)","Ensure only one artifact file reaches the post-processor (drop extra artifacts in prior post-processors or filter builds)","Split the build so each compression run handles one artifact"],"exampleFix":"// before: plain compression of multi-file artifact\n{\"type\": \"compress\"}\n// after: archive multiple inputs\n{\"type\": \"compress\", \"output\": \"output.tar.gz\"}","handlingStrategy":"validation","validationCode":"if len(artifact.Files) > 1 && !strings.HasSuffix(cfg.OutputPath, \".tar\") && !strings.Contains(cfg.OutputPath, \".tar.\") && !strings.HasSuffix(cfg.OutputPath, \".zip\") {\n    return fmt.Errorf(\"multiple input files require tar/zip output\")\n}","typeGuard":null,"tryCatchPattern":"_, _, _, err := pp.PostProcess(ctx, ui, artifact)\nif errors.Is(err, compress.ErrWrongInputCount) {\n    // re-run with a tar/zip output path or with a single-file artifact\n}","preventionTips":["Use tar/zip output when the builder emits multiple files","Ensure upstream post-processors pass exactly one artifact file","Name output with a .tar/.zip-derived extension when archiving multiple inputs"],"tags":["configuration","compression","artifacts"],"backgroundTag":"invalid-input-count","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"}