{"record":{"id":"e988fca28bc73195","repo":"coredns/coredns","slug":"percentage-should-fall-in-range-10-90-d","errorCode":null,"errorMessage":"percentage should fall in range [10, 90]: %d","messagePattern":"percentage should fall in range \\[10, 90\\]: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/cache/setup.go","lineNumber":170,"sourceCode":"\t\t\t\t\tdur, err := time.ParseDuration(args[1])\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tca.duration = dur\n\t\t\t\t}\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tpct := args[2]\n\t\t\t\t\tif x := pct[len(pct)-1]; x != '%' {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"last character of percentage should be `%%`, but is: %q\", x)\n\t\t\t\t\t}\n\t\t\t\t\tpct = pct[:len(pct)-1]\n\n\t\t\t\t\tnum, err := strconv.Atoi(pct)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif num < 10 || num > 90 {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"percentage should fall in range [10, 90]: %d\", num)\n\t\t\t\t\t}\n\t\t\t\t\tca.percentage = num\n\t\t\t\t}\n\n\t\t\tcase \"serve_stale\":\n\t\t\t\tserveStaleConfigured = true\n\t\t\t\targs := c.RemainingArgs()\n\t\t\t\tif len(args) > 5 {\n\t\t\t\t\treturn nil, c.ArgErr()\n\t\t\t\t}\n\t\t\t\tca.staleUpTo = 1 * time.Hour\n\t\t\t\tca.staleTTL = 0\n\t\t\t\tca.staleRecheck = 0\n\t\t\t\tif len(args) > 0 {\n\t\t\t\t\td, err := time.ParseDuration(args[0])\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/coredns/coredns/blob/558c9757a92b361e550bdba82d0b4ddf3d12d595/plugin/cache/setup.go#L152-L188","documentation":"After stripping the '%', cacheParse parses the prefetch percentage as an integer and requires it to fall within [10, 90]. Values below 10 or above 90 (e.g. `5%` or `95%`) are rejected to keep prefetch triggering within a sane band of the record's TTL.","triggerScenarios":"Corefile line like `prefetch 10 1m 5%` or `prefetch 10 1m 95%` inside a cache block; any integer percentage parsed from args[2] outside 10..90.","commonSituations":"Trying to make prefetch nearly always trigger (95-100%) or nearly never (small %), migrating from configs where other bounds were allowed, or guessing at valid ranges.","solutions":["Choose a percentage between 10 and 90, e.g. `prefetch 10 1m 30%`.","If you want aggressive prefetching, use 90%, the maximum allowed.","If you want minimal prefetching, use 10%, the minimum allowed.","Omit the percentage argument to use the default."],"exampleFix":"// before (Corefile)\ncache 30\n    prefetch 10 1m 95%\n\n// after\ncache 30\n    prefetch 10 1m 90%","handlingStrategy":"validation","validationCode":"const num = parseInt('90%'.slice(0, -1), 10); if (num < 10 || num > 90) { throw new Error(`prefetch percentage must be within [10, 90], got ${num}`); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp generated percentages into the 10-90 range.","Use the plugin defaults if extreme trigger thresholds are desired.","Document the [10, 90] bound in config-generation tooling."],"tags":["coredns","cache","prefetch","range","config"],"backgroundTag":"value-out-of-range","analyzedSha":"558c9757a92b361e550bdba82d0b4ddf3d12d595","analyzedAt":"2026-09-06T22:47:02.106Z","contentChangedAt":"2026-09-06T22:47:02.106Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}