hashicorp/packer · error

packer destination path missing from configs: this is an int

Error message

packer destination path missing from configs: this is an internal error

What it means

Returned by processSBOMForHCP (provisioner/hcp-sbom/provisioner.go:887) when the generatedData map passed into the provisioner lacks a usable "dst" string key holding the local Packer SBOM destination path. The message explicitly labels it an internal error: callers (provisionWithExistingSBOM / provisionWithNativeGeneration) are expected to always populate this key, so hitting it indicates a Packer plumbing bug or a non-standard invocation.

Source

Thrown at provisioner/hcp-sbom/provisioner.go:887

	cmd.Wait()
	if cmd.ExitStatus() != 0 {
		ui.Error(fmt.Sprintf("Cleanup command failed for %s with exit status %d", remotePath, cmd.ExitStatus()))
	}
}

// processSBOMForHCP validates, compresses, and prepares SBOM for HCP upload
func (p *Provisioner) processSBOMForHCP(generatedData map[string]interface{}, sbomData []byte) error {
	// Validate SBOM format
	format, err := validateSBOM(sbomData)
	if err != nil {
		return fmt.Errorf("SBOM validation failed: %s", err)
	}

	// Get destination path from generatedData
	pkrDst, ok := generatedData["dst"].(string)
	if !ok || pkrDst == "" {
		return fmt.Errorf("packer destination path missing from configs: this is an internal error")
	}

	// Write PackerSBOM to destination
	outFile, err := os.Create(pkrDst)
	if err != nil {
		return fmt.Errorf("failed to create output file %q: %s", pkrDst, err)
	}
	defer func() {
		_ = outFile.Close() // Cleanup, ignore error
	}()

	err = json.NewEncoder(outFile).Encode(PackerSBOM{
		RawSBOM: sbomData,
		Format:  format,
		Name:    p.config.SbomName,
	})
	if err != nil {
		return fmt.Errorf("failed to write SBOM to %q: %s", pkrDst, err)

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Upgrade to the latest Packer release — if the stock binary hits this, it is a bug worth reporting with PACKER_LOG=1 output.
  2. If you run a forked/patched build, diff your changes against upstream for the code that populates generatedData["dst"].
  3. If invoking programmatically, ensure the map contains a non-empty string at key "dst" before calling processSBOMForHCP.
  4. Reproduce with an unmodified `packer build` and minimal template to rule out local modifications.
  5. Check the provisioner's own generatedData construction (Provision path) for regressions if you maintain a fork.

Example fix

// before (custom caller): map missing dst
data := map[string]interface{}{"src": srcPath}
err := p.processSBOMForHCP(data, sbomData)
// after: provide the required destination key
data := map[string]interface{}{"src": srcPath, "dst": dstPath}
err := p.processSBOMForHCP(data, sbomData)
Defensive patterns

Strategy: validation

Validate before calling

// Guard before calling processing (or when embedding the provisioner)
dst, ok := generatedData["dst"].(string)
if !ok || dst == "" { /* internal plumbing broken: fail fast with context */ }

Type guard

func hasDst(generatedData map[string]interface{}) (string, bool) {
    dst, ok := generatedData["dst"].(string)
    return dst, ok && dst != ""
}

Try / catch

if err := p.processSBOMForHCP(generatedData, sbomData); err != nil {
    if strings.Contains(err.Error(), "internal error") { /* upgrade Packer / file bug */ }
    return err
}

Prevention

When it happens

Trigger: processSBOMForHCP is invoked with a generatedData map where generatedData["dst"] is absent, nil, or not a string — e.g. an internal refactor/regression in the provisioner, or calling the provisioner through custom code that builds generatedData manually instead of via the normal Provision path.

Common situations: Running a patched or forked Packer binary where the SBOM config plumbing changed; a genuine upstream bug in a specific version; embedding/invoking this provisioner programmatically with a hand-built data map; type assertion failing because dst was stored under a different key or as a non-string type.

Related errors


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