hashicorp/packer · error

the `url` must be specified

Error message

the `url` must be specified

What it means

The http datasource validates its config in Configure and requires a `url` field. Because there is no URL to issue the HTTP request against, configuration fails immediately before any build work happens.

Source

Thrown at datasource/http/data.go:66

	ResponseHeaders map[string]string `mapstructure:"request_headers"`
}

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.Url == "" {
		errs = packersdk.MultiErrorAppend(
			errs,
			fmt.Errorf("the `url` must be specified"))
	}

	// Default to GET if no method is specified
	if d.config.Method == "" {
		d.config.Method = "GET"
	}

	// Check if the input is in the list of allowed methods
	validMethod := false
	allowedMethods := []string{"HEAD", "GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"}
	for _, method := range allowedMethods {
		if method == d.config.Method {
			validMethod = true
			break
		}
	}
	if !validMethod {
		errs = packersdk.MultiErrorAppend(

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Add a valid `url` attribute to the http datasource block
  2. Check that any variable/locals used in `url` are non-empty at evaluation time
  3. Run `packer validate` to catch this before a build

Example fix

// before
datastore "http" "release" {
}
// after
datastore "http" "release" {
  url = "https://example.com/metadata.json"
}
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate datasource input in locals
locals { release_url = var.release_url != "" ? var.release_url : "https://default.example.com/metadata.json" }

Prevention

When it happens

Trigger: Declaring an http datasource block whose `url` attribute is absent or set to an empty string "".

Common situations: Copy-pasted datasource block with the url left as a placeholder, an interpolated variable resolving to "", or the attribute simply forgotten.

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/b59924aead395999. Report an issue: GitHub.