caddyserver/caddy · error

compiling regexp pattern

Error message

compiling regexp pattern %d (%s): %v

What it means

MultiRegexpFilter.Provision wraps regexp.Compile failing for the i-th operation's pattern (RE2, linear-time and ReDoS-safe): the pattern passed length/emptiness checks but is syntactically invalid; index, pattern, and compiler error are reported.

Solutions

  1. Fix the regexp pattern syntax at the given index; the wrapped error explains the compile failure.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/logging/filters.go:925 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/f19b00381d0e3c78. Report an issue: GitHub.

Appendix: source

Thrown at modules/logging/filters.go:925

	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)
		r, err := regexp.Compile(f.Operations[i].RawRegexp)
		if err != nil {
			return fmt.Errorf("compiling regexp pattern %d (%s): %v", i, f.Operations[i].RawRegexp, err)
		}
		f.Operations[i].regexp = r
	}
	return nil
}

// Validate ensures the filter is properly configured with security checks.
func (f *MultiRegexpFilter) Validate() error {
	if len(f.Operations) == 0 {
		return fmt.Errorf("multi_regexp filter requires at least one operation")
	}

	if len(f.Operations) > maxRegexpOperations {
		return fmt.Errorf("too many regexp operations: %d (maximum %d allowed)", len(f.Operations), maxRegexpOperations)
	}

	for i, op := range f.Operations {
		if op.RawRegexp == "" {

View on GitHub (pinned to 50e54ee279)