caddyserver/caddy · error

too many regexp operations: %d (maximum %d allowed)

Error message

too many regexp operations: %d (maximum %d allowed)

What it means

Error "too many regexp operations: %d (maximum %d allowed)" thrown in caddyserver/caddy.

Source

Thrown at modules/logging/filters.go:904

			f.Operations = append(f.Operations, op)
		default:
			return d.Errf("unrecognized subdirective %s", d.Val())
		}
	}

	// Security check: ensure at least one operation is defined
	if len(f.Operations) == 0 {
		return d.Err("multi_regexp filter requires at least one regexp operation")
	}

	return nil
}

// Provision compiles all regexp patterns with security validation.
func (f *MultiRegexpFilter) Provision(ctx caddy.Context) error {
	// Security check: validate operation count
	if len(f.Operations) > maxRegexpOperations {
		return fmt.Errorf("too many regexp operations: %d (maximum %d allowed)", len(f.Operations), maxRegexpOperations)
	}

	if len(f.Operations) == 0 {
		return fmt.Errorf("multi_regexp filter requires at least one operation")
	}

	for i := range f.Operations {
		// Security validation: pattern length check
		if len(f.Operations[i].RawRegexp) > maxPatternLength {
			return fmt.Errorf("regexp pattern %d too long: %d characters (maximum %d)", i, len(f.Operations[i].RawRegexp), maxPatternLength)
		}

		// Security validation: empty pattern check
		if f.Operations[i].RawRegexp == "" {
			return fmt.Errorf("regexp pattern %d cannot be empty", i)
		}

		// Compile and validate the pattern (uses RE2 engine - safe from ReDoS)

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Reduce the number of regexp operations to the allowed maximum.

When it happens

Trigger: Thrown at modules/logging/filters.go:904 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/736182c991d11d9d. Report an issue: GitHub.