hashicorp/packer · error

Unknown data source %s

Error message

Unknown data source %s

What it means

MapOfDatasource.Start returns this error when the requested data source name is not registered in the map. It means a data block in the template references a data source plugin Packer does not know about.

Source

Thrown at packer/maps.go:107

	}
	return res
}

type MapOfDatasource map[string]func() (packersdk.Datasource, error)

func (mod MapOfDatasource) Has(dataSource string) bool {
	_, res := mod[dataSource]
	return res
}

func (mod MapOfDatasource) Set(dataSource string, starter func() (packersdk.Datasource, error)) {
	mod[dataSource] = starter
}

func (mod MapOfDatasource) Start(dataSource string) (packersdk.Datasource, error) {
	d, found := mod[dataSource]
	if !found {
		return nil, fmt.Errorf("Unknown data source %s", dataSource)
	}
	return d()
}

func (mod MapOfDatasource) List() []string {
	res := []string{}
	for k := range mod {
		res = append(res, k)
	}
	return res
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Correct the data source type in the template.
  2. Run `packer init .` so the data source plugin is installed.
  3. Verify the plugin binary exists with the correct packer-plugin-* naming.
  4. In embedded Go usage, call Set() for the data source before Start().

Example fix

// before
data "htpp" { ... }

// after
data "http" { ... }
Defensive patterns

Strategy: validation

Validate before calling

if !dataSources.Has(name) {
    return fmt.Errorf("data source %q not installed; known: %v", name, dataSources.List())
}
ds, err := dataSources.Start(name)

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "Unknown data source") { /* run packer init */ }
}

Prevention

When it happens

Trigger: Calling Start(dataSource) with an unregistered name: a data block type misspelled (e.g. "http" vs "curl"), a data source plugin not installed via `packer init`, or Start invoked before Set() registration in embedded usage.

Common situations: Typo in a data block's type attribute; using a third-party data source without declaring it in required_plugins; plugin binary missing from the plugin directory; casing mismatch (lookup is case-sensitive).

Related errors


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