hashicorp/nomad · error

Artifact %d validation failed: %v

Error message

Artifact %d validation failed: %v

What it means

Emitted in Task validation (nomad/structs/structs.go:8319) when an Artifact in the task fails Artifact.Validate(). It wraps the inner error with the 1-based artifact index; inner causes include invalid source URLs, unsupported schemes, or a destination missing/not absolute.

Source

Thrown at nomad/structs/structs.go:8319

		}
	} else {
		for idx, affinity := range t.Affinities {
			if err := affinity.Validate(); err != nil {
				outer := fmt.Errorf("Affinity %d validation failed: %s", idx+1, err)
				mErr.Errors = append(mErr.Errors, outer)
			}
		}
	}

	// Validate Services
	if err := validateServices(t, tg.Networks); err != nil {
		mErr.Errors = append(mErr.Errors, err)
	}

	// Validate artifacts.
	for idx, artifact := range t.Artifacts {
		if err := artifact.Validate(); err != nil {
			outer := fmt.Errorf("Artifact %d validation failed: %v", idx+1, err)
			mErr.Errors = append(mErr.Errors, outer)
		}
	}

	// Validate Vault.
	if t.Vault != nil {
		if err := t.Vault.Validate(); err != nil {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("Vault validation failed: %v", err))
		}
	}

	// Validate templates.
	destinations := make(map[string]int, len(t.Templates))
	for idx, tmpl := range t.Templates {
		if err := tmpl.Validate(); err != nil {
			outer := fmt.Errorf("Template %d validation failed: %s", idx+1, err)
			mErr.Errors = append(mErr.Errors, outer)
		}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the wrapped inner error to see which artifact (index N from 1) and why.
  2. Give source a full URL with supported scheme (http, https, s3, git, etc.).
  3. Make destination an absolute path inside the alloc dir, e.g. "/local/file.tgz".
  4. Verify checksum syntax: algorithm colon hex digest, e.g. checksum = "sha256:abcd...".

Example fix

// before
artifact {
  source      = "example.com/app.tgz"
  destination = "local/app"
}
// after
artifact {
  source      = "https://example.com/app.tgz"
  destination = "/local/app.tgz"
}
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(a.Source)
if err != nil || u.Scheme == "" {
  return fmt.Errorf("artifact %d: source must be an absolute URL with scheme", idx+1)
}
if !filepath.IsAbs(a.RelativeDest) {
  return fmt.Errorf("artifact %d: destination must be absolute", idx+1)
}

Type guard

func validArtifactSource(src string) bool {
  u, err := url.Parse(src)
  return err == nil && u.Scheme != "" && u.Host != ""
}

Prevention

When it happens

Trigger: Task artifact block with source lacking a scheme or using an unsupported one, destination not an absolute path, or checksum format errors; detected when the job is validated.

Common situations: Users write source = "example.com/file.tgz" without https://; relative destination paths like "local/" omitted leading slash misuse; malformed checksums = "md5:xxx" values.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/404e66c8f6dbec25. Report an issue: GitHub.