hashicorp/packer · error
ErrWrongInputCount
ErrWrongInputCount
Error message
Can only have 1 input file when not using tar/zip
What it means
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.
Source
Thrown at post-processor/compress/post-processor.go:37
"github.com/biogo/hts/bgzf"
"github.com/dsnet/compress/bzip2"
"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
"github.com/klauspost/pgzip"
"github.com/pierrec/lz4/v4"
"github.com/ulikunitz/xz"
)
var (
// ErrInvalidCompressionLevel is returned when the compression level passed
// to gzip is not in the expected range. See compress/flate for details.
ErrInvalidCompressionLevel = fmt.Errorf(
"Invalid compression level. Expected an integer from -1 to 9.")
ErrWrongInputCount = fmt.Errorf(
"Can only have 1 input file when not using tar/zip")
filenamePattern = regexp.MustCompile(`(?:\.([a-z0-9]+))`)
)
type Config struct {
common.PackerConfig `mapstructure:",squash"`
// Fields from config file
OutputPath string `mapstructure:"output"`
Format string `mapstructure:"format"`
CompressionLevel int `mapstructure:"compression_level"`
// Derived fields
Archive string
Algorithm string
ctx interpolate.ContextView on GitHub (pinned to eb36e3c3e4)
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
Example fix
// before: plain compression of multi-file artifact
{"type": "compress"}
// after: archive multiple inputs
{"type": "compress", "output": "output.tar.gz"} Defensive patterns
Strategy: validation
Validate before calling
if len(artifact.Files) > 1 && !strings.HasSuffix(cfg.OutputPath, ".tar") && !strings.Contains(cfg.OutputPath, ".tar.") && !strings.HasSuffix(cfg.OutputPath, ".zip") {
return fmt.Errorf("multiple input files require tar/zip output")
} Try / catch
_, _, _, err := pp.PostProcess(ctx, ui, artifact)
if errors.Is(err, compress.ErrWrongInputCount) {
// re-run with a tar/zip output path or with a single-file artifact
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- ErrInvalidCompressionLevel
- error creating %s writer: %s
- signing_mode %q requires signer
- build keyless identity policy: %w
- signing_mode %q requires keyless_identity and keyless_oidc_i
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/e1ab7cacc9e6de96.
Report an issue: GitHub.