hashicorp/packer · error

The `input` must be specified

Error message

The `input` must be specified

What it means

The null datasource simply echoes its `input` back into template data; Configure requires a non-empty `input` string. An empty input is treated as a configuration mistake since the datasource would be useless.

Source

Thrown at datasource/null/data.go:46

	common.PackerConfig `mapstructure:",squash"`
	// This variable will get stored as "output" in the output spec.
	Input string `mapstructure:"input" required:"true"`
}

func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
	return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
	err := config.Decode(&d.config, nil, raws...)
	if err != nil {
		return err
	}

	var errs *packersdk.MultiError

	if d.config.Input == "" {
		errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The `input` must be specified"))
	}

	if errs != nil && len(errs.Errors) > 0 {
		return errs
	}
	return nil
}

type DatasourceOutput struct {
	// Output will return the input variable, as output.
	Output string `mapstructure:"output"`
}

func (d *Datasource) OutputSpec() hcldec.ObjectSpec {
	return (&DatasourceOutput{}).FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Execute() (cty.Value, error) {

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Add a non-empty `input` value to the datasource block
  2. Ensure any variable interpolated into `input` has a non-empty default or is provided
  3. Run `packer validate` to catch empty inputs early

Example fix

// before
data "null" "data" {
  input = var.maybe_empty
}
// after
data "null" "data" {
  input = coalesce(var.maybe_empty, "default-value")
}
Defensive patterns

Strategy: validation

Validate before calling

locals { null_input = var.input != "" ? var.input : "default" }

Prevention

When it happens

Trigger: A `data "null"` block with no `input` attribute, or input interpolating to an empty string (e.g. an unset variable).

Common situations: Template authors using the null datasource as a placeholder and forgetting the input, or a variable defaulting to "".

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/23bbd5cd161e42e7. Report an issue: GitHub.