caddyserver/caddy · error

regexp pattern %d cannot be empty

Error message

regexp pattern %d cannot be empty

What it means

Error "regexp pattern %d cannot be empty" thrown in caddyserver/caddy.

Source

Thrown at modules/logging/filters.go:919

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

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Provide a non-empty regexp pattern for each operation.

When it happens

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