hashicorp/nomad · error
SecretsMB value (%d) cannot be negative
Error message
SecretsMB value (%d) cannot be negative
What it means
Resources.Validate() rejects a negative SecretsMB. Reserved secret memory is a byte count and only non-negative values are meaningful; negative values would corrupt accounting in the scheduler and driver. -1 is not accepted here as a sentinel (unlike memory_max).
Source
Thrown at nomad/structs/structs.go:2473
}
}
// Ensure the numa block is valid
if err := r.NUMA.Validate(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}
// Ensure memory_max is greater than memory, unless it is set to 0 or -1 which
// are both sentinel values
if (r.MemoryMaxMB != 0 && r.MemoryMaxMB != MemoryNoLimit) && r.MemoryMaxMB < r.MemoryMB {
mErr.Errors = append(mErr.Errors, fmt.Errorf("MemoryMaxMB value (%d) should be larger than MemoryMB value (%d)", r.MemoryMaxMB, r.MemoryMB))
}
if r.SecretsMB > r.MemoryMB {
mErr.Errors = append(mErr.Errors, fmt.Errorf("SecretsMB value (%d) cannot be larger than MemoryMB value (%d)", r.SecretsMB, r.MemoryMB))
}
if r.SecretsMB < 0 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("SecretsMB value (%d) cannot be negative", r.SecretsMB))
}
return mErr.ErrorOrNil()
}
// Merge merges this resource with another resource.
// COMPAT(0.10): Remove in 0.10
func (r *Resources) Merge(other *Resources) {
if other.CPU != 0 {
r.CPU = other.CPU
}
if other.Cores != 0 {
r.Cores = other.Cores
}
if other.MemoryMB != 0 {
r.MemoryMB = other.MemoryMB
}
if other.MemoryMaxMB != 0 {View on GitHub (pinned to 482b49bf1a)
Solutions
- Set SecretsMB (secrets_mb) to 0 or a positive integer
- Remove secrets_mb from the resources block entirely if unused
Example fix
// before
resources {
secrets_mb = -1
}
// after
resources {
secrets_mb = 0
} Defensive patterns
Strategy: validation
Validate before calling
if r.SecretsMB < 0 {
return fmt.Errorf("secrets_mb (%d) must be >= 0", r.SecretsMB)
} Type guard
func nonNegative(n int) bool { return n >= 0 } Prevention
- Don't use -1 as an unset sentinel for secrets_mb; omit the field instead
- Clamp computed values with max(0, x) when templating resources
When it happens
Trigger: Submitting a job whose task Resources has SecretsMB < 0, e.g. secrets_mb = -1.
Common situations: Using -1 to mean 'unset' as one might with other memory fields; arithmetic producing negative values when templating resources; typo of a leading minus sign.
Related errors
- Missing task resources
- MemoryMaxMB value (%d) should be larger than MemoryMB value
- SecretsMB value (%d) cannot be larger than MemoryMB value (%
- minimum CPU value is %d; got %d
- minimum MemoryMB value is %d; got %d
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/60c3c1faa7bd105c.
Report an issue: GitHub.