hashicorp/nomad · error

git_timeout must be > 0

Error message

git_timeout must be > 0

What it means

Artifact config validation parsed git_timeout but found a negative duration; the timeout must be zero or positive.

Source

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

		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)
	} else if v < 0 {
		return fmt.Errorf("s3_timeout must be > 0")

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set git_timeout to a positive duration such as "10s"
  2. Remove the negative value so defaults apply

Example fix

// before
artifact {
  git_timeout = "-5m"
}
// after
artifact {
  git_timeout = "15m"
}
Defensive patterns

Strategy: validation

Validate before calling

func nonNegativeGitTimeout(s string) bool {
    v, err := time.ParseDuration(s)
    return err == nil && v >= 0
}

Type guard

func isPositiveDuration(s string) bool {
    v, err := time.ParseDuration(s)
    return err == nil && v >= 0
}

Prevention

When it happens

Trigger: Setting `git_timeout = "-5m"` or "-1s"; computed/templated values producing negatives; accidental minus sign in HCL.

Common situations: Dynamic timeout arithmetic going negative; sentinel-value confusion (using -1 for 'unlimited'); sign typos during manual editing.

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