{"record":{"id":"84681f9f6b70415a","repo":"thanos-io/thanos","slug":"auto-gomemlimit-ratio-must-be-greater-than-0-and","errorCode":null,"errorMessage":"--auto-gomemlimit.ratio must be greater than 0 and less than or equal to 1.","messagePattern":"--auto-gomemlimit\\.ratio must be greater than 0 and less than or equal to 1\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/config.go","lineNumber":371,"sourceCode":"\tcmd.Flag(\"enable-auto-gomemlimit\",\n\t\t\"Enable go runtime to automatically limit memory consumption.\").\n\t\tDefault(\"false\").BoolVar(&gml.enableAutoGoMemlimit)\n\n\tcmd.Flag(\"auto-gomemlimit.ratio\",\n\t\t\"The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory.\").\n\t\tDefault(\"0.9\").FloatVar(&gml.memlimitRatio)\n\n\treturn gml\n}\n\nfunc configureGoAutoMemLimit(common goMemLimitConfig) (int64, error) {\n\tvar (\n\t\terr    error\n\t\tlimits int64 = -1\n\t)\n\n\tif common.memlimitRatio <= 0.0 || common.memlimitRatio > 1.0 {\n\t\treturn limits, errors.New(\"--auto-gomemlimit.ratio must be greater than 0 and less than or equal to 1.\")\n\t}\n\n\tif common.enableAutoGoMemlimit {\n\t\tlimits, err = memlimit.SetGoMemLimitWithOpts(\n\t\t\tmemlimit.WithRatio(common.memlimitRatio),\n\t\t\tmemlimit.WithProvider(\n\t\t\t\tmemlimit.ApplyFallback(\n\t\t\t\t\tmemlimit.FromCgroup,\n\t\t\t\t\tmemlimit.FromSystem,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn -1, errors.Wrap(err, \"Failed to set GOMEMLIMIT automatically\")\n\t\t}\n\t}\n\n\treturn limits, nil","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/config.go#L353-L389","documentation":"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).","triggerScenarios":"Starting any Thanos command with --auto-gomemlimit.ratio=0, a negative value like =-0.5, or =1.5.","commonSituations":"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.","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."],"exampleFix":"// before\nthanos query --auto-gomemlimit.ratio=1.5\n// after\nthanos query --auto-gomemlimit.ratio=0.9","handlingStrategy":"validation","validationCode":"func memlimitRatioValid(r float64) bool { return r > 0.0 && r <= 1.0 }","typeGuard":null,"tryCatchPattern":"// Go\nlimits, err := configureGoAutoMemLimit(common)\nif err != nil && strings.Contains(err.Error(), \"auto-gomemlimit.ratio\") {\n    return fmt.Errorf(\"flag config: %w\", err) // do not retry; fix the flag\n}","preventionTips":["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."],"tags":["cli","config","gomemlimit","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}