coredns/coredns · error

percentage should fall in range [10, 90]: %d

Error message

percentage should fall in range [10, 90]: %d

What it means

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.

Source

Thrown at plugin/cache/setup.go:170

					dur, err := time.ParseDuration(args[1])
					if err != nil {
						return nil, err
					}
					ca.duration = dur
				}
				if len(args) > 2 {
					pct := args[2]
					if x := pct[len(pct)-1]; x != '%' {
						return nil, fmt.Errorf("last character of percentage should be `%%`, but is: %q", x)
					}
					pct = pct[:len(pct)-1]

					num, err := strconv.Atoi(pct)
					if err != nil {
						return nil, err
					}
					if num < 10 || num > 90 {
						return nil, fmt.Errorf("percentage should fall in range [10, 90]: %d", num)
					}
					ca.percentage = num
				}

			case "serve_stale":
				serveStaleConfigured = true
				args := c.RemainingArgs()
				if len(args) > 5 {
					return nil, c.ArgErr()
				}
				ca.staleUpTo = 1 * time.Hour
				ca.staleTTL = 0
				ca.staleRecheck = 0
				if len(args) > 0 {
					d, err := time.ParseDuration(args[0])
					if err != nil {
						return nil, err
					}

View on GitHub (pinned to 558c9757a9)

Solutions

  1. Choose a percentage between 10 and 90, e.g. `prefetch 10 1m 30%`.
  2. If you want aggressive prefetching, use 90%, the maximum allowed.
  3. If you want minimal prefetching, use 10%, the minimum allowed.
  4. Omit the percentage argument to use the default.

Example fix

// before (Corefile)
cache 30
    prefetch 10 1m 95%

// after
cache 30
    prefetch 10 1m 90%
Defensive patterns

Strategy: validation

Validate before calling

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}`); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of coredns/coredns@558c9757a9 (2026-09-06). Data as JSON: /api/errors/e988fca28bc73195. Report an issue: GitHub.