thanos-io/thanos · error
--auto-gomemlimit.ratio must be greater than 0 and less…
Error message
--auto-gomemlimit.ratio must be greater than 0 and less than or equal to 1.
What it means
configureGoAutoMemLimit validates the --auto-gomemlimit.ratio flag before calling memlimit.SetGoMemLimitWithOpts. The ratio must be in the interval (0, 1]; values <= 0 or > 1 are rejected with this explicit error and GOMEMLIMIT is not configured (limits stays -1).
Solutions
- Set the ratio within (0, 1], e.g. --auto-gomemlimit.ratio=0.9.
- To express a percentage, convert: 90% -> 0.9.
- If you want the feature off, don't set the ratio; disable via the enable flag instead of an out-of-range value.
Example fix
// before thanos query --auto-gomemlimit.ratio=1.5 // after thanos query --auto-gomemlimit.ratio=0.9
Defensive patterns
Strategy: validation
Validate before calling
func memlimitRatioValid(r float64) bool { return r > 0.0 && r <= 1.0 } Try / catch
// Go
limits, err := configureGoAutoMemLimit(common)
if err != nil && strings.Contains(err.Error(), "auto-gomemlimit.ratio") {
return fmt.Errorf("flag config: %w", err) // do not retry; fix the flag
} Prevention
- Express ratios as decimals in (0,1], never percentages (0.9, not 90).
- Template Helm/compose values with a clamp or assertion on the range.
- Document that 0 and >1 are invalid; use the enable flag to turn the feature off.
When it happens
Trigger: Starting any Thanos command with --auto-gomemlimit.ratio=0, a negative value like =-0.5, or =1.5.
Common situations: Misreading the flag semantics (thinking 0 disables it or that >1 means "allow more than available"); copy-paste mistakes in unit files or Helm values; type confusion passing a percentage like 90 instead of 0.9.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- unsupported format for label
- error validating the config
- Address is duplicated for --query flag.
- level is bigger then default set of
- unknown sync strategy
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/84681f9f6b70415a.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/config.go:371
cmd.Flag("enable-auto-gomemlimit",
"Enable go runtime to automatically limit memory consumption.").
Default("false").BoolVar(&gml.enableAutoGoMemlimit)
cmd.Flag("auto-gomemlimit.ratio",
"The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory.").
Default("0.9").FloatVar(&gml.memlimitRatio)
return gml
}
func configureGoAutoMemLimit(common goMemLimitConfig) (int64, error) {
var (
err error
limits int64 = -1
)
if common.memlimitRatio <= 0.0 || common.memlimitRatio > 1.0 {
return limits, errors.New("--auto-gomemlimit.ratio must be greater than 0 and less than or equal to 1.")
}
if common.enableAutoGoMemlimit {
limits, err = memlimit.SetGoMemLimitWithOpts(
memlimit.WithRatio(common.memlimitRatio),
memlimit.WithProvider(
memlimit.ApplyFallback(
memlimit.FromCgroup,
memlimit.FromSystem,
),
),
)
if err != nil {
return -1, errors.Wrap(err, "Failed to set GOMEMLIMIT automatically")
}
}
return limits, nilView on GitHub (pinned to 35b8b99117)