hashicorp/nomad · error

git_timeout not a valid duration: %w

Error message

git_timeout not a valid duration: %w

What it means

Returned by ArtifactConfig.Validate when git_timeout is set but time.ParseDuration cannot parse the string. The value must be a Go duration literal such as "5m", "30s", "1h"; the wrapped error describes the syntax problem.

Source

Thrown at nomad/structs/config/artifact.go:197

		return fmt.Errorf("http_max_size not a valid size: %w", err)
	} else if v > math.MaxInt64 {
		return fmt.Errorf("http_max_size must be < %d but found %d", int64(math.MaxInt64), v)
	}

	if a.GCSTimeout == nil {
		return fmt.Errorf("gcs_timeout must be set")
	}
	if v, err := time.ParseDuration(*a.GCSTimeout); err != nil {
		return fmt.Errorf("gcs_timeout not a valid duration: %w", err)
	} else if v < 0 {
		return fmt.Errorf("gcs_timeout must be > 0")
	}

	if a.GitTimeout == nil {
		return fmt.Errorf("git_timeout must be set")
	}
	if v, err := time.ParseDuration(*a.GitTimeout); err != nil {
		return fmt.Errorf("git_timeout not a valid duration: %w", err)
	} else if v < 0 {
		return fmt.Errorf("git_timeout must be > 0")
	}

	if a.HgTimeout == nil {
		return fmt.Errorf("hg_timeout must be set")
	}
	if v, err := time.ParseDuration(*a.HgTimeout); err != nil {
		return fmt.Errorf("hg_timeout not a valid duration: %w", err)
	} else if v < 0 {
		return fmt.Errorf("hg_timeout must be > 0")
	}

	if a.S3Timeout == nil {
		return fmt.Errorf("s3_timeout must be set")
	}
	if v, err := time.ParseDuration(*a.S3Timeout); err != nil {
		return fmt.Errorf("s3_timeout not a valid duration: %w", err)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use a valid Go duration string, e.g. `git_timeout = "5m"` or "300s".
  2. Append the unit when values come from templates/env vars.
  3. Inspect the wrapped %w error for the exact invalid segment.
  4. Validate with `nomad validate` before restarting.

Example fix

// before
artifact {
  git_timeout = "300"
}
// after
artifact {
  git_timeout = "300s"
}
Defensive patterns

Strategy: validation

Validate before calling

func validGitTimeout(s *string) bool {
    if s == nil { return false }
    _, err := time.ParseDuration(*s)
    return err == nil
}

Type guard

func isDuration(s string) bool {
    _, err := time.ParseDuration(s)
    return err == nil
}

Prevention

When it happens

Trigger: Setting `git_timeout` to "5" (missing unit), "5 minutes", "5min", "", or a substituted numeric value without a suffix; typos or locale-formatted numbers like "5,5m".

Common situations: Mixing integer-seconds conventions from other tools with Go duration syntax; environment variable substitution dropping units; hand-editing configs quickly and omitting the unit.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


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