caddyserver/caddy · warning

no know function was given

Error message

no know function was given

What it means

Returned by the templates module's humanize function when the format-type prefix matches neither 'size' nor 'time' (the switch falls through to the default). Note the message itself contains an upstream typo ('no know function') - it is about the humanize sub-function, not about missing template functions in general.

Source

Thrown at modules/caddyhttp/templates/tplcontext.go:501

		if dataerr != nil {
			return "", fmt.Errorf("humanize: size cannot be parsed: %s", dataerr.Error())
		}
		return humanize.Bytes(dataint), nil

	case "time":
		timelayout := time.RFC1123Z
		if len(parts) > 1 {
			timelayout = parts[1]
		}

		dataint, dataerr := time.Parse(timelayout, data)
		if dataerr != nil {
			return "", fmt.Errorf("humanize: time cannot be parsed: %s", dataerr.Error())
		}
		return humanize.Time(dataint), nil
	}

	return "", fmt.Errorf("no know function was given")
}

// funcMaybe invokes the plugged-in function named functionName if it is plugged in
// (is a module in the 'http.handlers.templates.functions' namespace). If it is not
// available, a log message is emitted.
//
// The first argument is the function name, and the rest of the arguments are
// passed on to the actual function.
//
// This function is useful for executing templates that use components that may be
// considered as optional in some cases (like during local development) where you do
// not want to require everyone to have a custom Caddy build to be able to execute
// your template.
//
// NOTE: This function is EXPERIMENTAL and subject to change or removal.
func (c TemplateContext) funcMaybe(functionName string, args ...any) (any, error) {
	for _, funcMap := range c.CustomFuncs {
		if fn, ok := funcMap[functionName]; ok {

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Use only 'size' or 'time' (optionally 'time:<layout>'): {{ humanize "size" "2048" }}
  2. Check spelling and case - the switch is case-sensitive
  3. If the format comes from a variable, validate it in the template before calling humanize
  4. For other formats (ordinal, comma) compute them with math functions in the template instead

Example fix

<!-- before -->
{{ humanize "bytes" "2048" }}

<!-- after -->
{{ humanize "size" "2048" }}
Defensive patterns

Strategy: validation

Validate before calling

{{ $fmt := .Format }}{{ if or (eq $fmt "size") (hasPrefix $fmt "time") }}{{ humanize $fmt .Data }}{{ else }}unsupported humanize format{{ end }}

Type guard

{{ $ok := or (eq (index (split .Format ":") 0) "size") (eq (index (split .Format ":") 0) "time") }}

Prevention

When it happens

Trigger: {{ humanize "bytes" "1024" }}, {{ humanize "date" "..." }}, or an empty format string {{ humanize "" ... }}; anything whose part before the optional ':' is not exactly size or time.

Common situations: Assuming humanize supports more formats than it does (it only supports size and time), typos like 'Size' (case-sensitive switch), or placeholder-driven format strings that resolve to unexpected values.

Related errors


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