caddyserver/caddy · error

multi_regexp filter requires at least one operation

Error message

multi_regexp filter requires at least one operation

What it means

MultiRegexpFilter.Provision guard: no regexp operations were configured, making the filter a no-op; provisioning rejects the empty configuration rather than silently passing logs through. (The Caddyfile unmarshaler enforces the same rule earlier via d.Err.)

Solutions

  1. Add at least one regexp operation to the multi_regexp filter.
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

Thrown at modules/logging/filters.go:908

	}

	// 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)
		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)
		}

View on GitHub (pinned to 50e54ee279)