hashicorp/nomad · error

decompression_file_count_limit must be >= 0 but found %d

Error message

decompression_file_count_limit must be >= 0 but found %d

What it means

Validate() enforces that decompression_file_count_limit is non-negative; a negative value fails with 'must be >= 0 but found %d'. A negative archive-file cap is meaningless and typically signals a config mistake rather than intent to disable the check.

Source

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

		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")
	}

	if a.DecompressionFileCountLimit == nil {
		return fmt.Errorf("decompression_file_count_limit must not be nil")
	}
	if v := *a.DecompressionFileCountLimit; v < 0 {
		return fmt.Errorf("decompression_file_count_limit must be >= 0 but found %d", v)
	}

	if a.DecompressionSizeLimit == nil {
		return fmt.Errorf("decompression_size_limit must not be nil")
	}
	if v, err := humanize.ParseBytes(*a.DecompressionSizeLimit); err != nil {
		return fmt.Errorf("decompression_size_limit is not a valid size: %w", err)
	} else if v > math.MaxInt64 {
		return fmt.Errorf("decompression_size_limit must be < %d but found %d", int64(math.MaxInt64), v)
	}

	if a.DisableArtifactInspection == nil {
		return fmt.Errorf("disable_artifact_inspection must be set")
	}

	if a.DisableFilesystemIsolation == nil {
		return fmt.Errorf("disable_filesystem_isolation must be set")
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Change decompression_file_count_limit to a non-negative integer, e.g. 0 (0 archives disallowed effectively) or a real cap like 10000.
  2. If 'unlimited' is desired, set the maximum int value that fits the platform rather than a negative number.
  3. Add a pre-validate check that clamps or rejects negative values at config-load time with a clearer message.

Example fix

// before
artifact {
  decompression_file_count_limit = -1
}
// after
artifact {
  decompression_file_count_limit = 10000
}
Defensive patterns

Strategy: validation

Validate before calling

if cfg.DecompressionFileCountLimit != nil && *cfg.DecompressionFileCountLimit < 0 {
    return fmt.Errorf("decompression_file_count_limit must be >= 0, got %d", *cfg.DecompressionFileCountLimit)
}

Type guard

func nonNegativeLimit(p *int) bool { return p != nil && *p >= 0 }

Prevention

When it happens

Trigger: Calling ArtifactConfig.Validate() when *a.DecompressionFileCountLimit < 0, e.g. -1 or -5000.

Common situations: Using -1 to mean 'unlimited' (not supported here); int truncation/overflow when the value is computed in Go or a template; typos like `=-0` or sign dropped in interpolation.

Related errors


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