caddyserver/caddy · error

CEL request matcher expects return type of bool, not %s

Error message

CEL request matcher expects return type of bool, not %s

What it means

Error "CEL request matcher expects return type of bool, not %s" thrown in caddyserver/caddy.

Source

Thrown at modules/caddyhttp/celmatcher.go:192

		ext.Bindings(),
		ext.Lists(),
		ext.Math(),
		matcherLib,
	)
	if err != nil {
		return fmt.Errorf("setting up CEL environment: %v", err)
	}

	// parse and type-check the expression
	checked, issues := env.Compile(m.expandedExpr)
	if issues.Err() != nil {
		return fmt.Errorf("compiling CEL program: %s", issues.Err())
	}

	// request matching is a boolean operation, so we don't really know
	// what to do if the expression returns a non-boolean type
	if checked.OutputType() != cel.BoolType {
		return fmt.Errorf("CEL request matcher expects return type of bool, not %s", checked.OutputType())
	}

	// compile the "program"
	m.prg, err = env.Program(checked, cel.EvalOptions(cel.OptOptimize))
	if err != nil {
		return fmt.Errorf("compiling CEL program: %s", err)
	}
	return nil
}

// Match returns true if r matches m.
func (m MatchExpression) Match(r *http.Request) bool {
	match, err := m.MatchWithError(r)
	if err != nil {
		SetVar(r.Context(), MatcherErrorVarKey, err)
	}
	return match
}

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Change the CEL expression so it evaluates to a boolean, for example by adding a comparison.

When it happens

Trigger: Thrown at modules/caddyhttp/celmatcher.go:192 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/e5ff278e160cd42e. Report an issue: GitHub.