caddyserver/caddy · error
too many '<' for heredoc on line #
Error message
too many '<' for heredoc on line #%d; only use two, for example <<END
What it means
The Caddyfile lexer rejects a heredoc opener written with three or more '<' characters. When a line ends and the accumulated heredoc marker buffer starts with '<<<', the input is not a valid heredoc token, so tokenization fails for the current line.
Solutions
- Change <<<MARKER to <<MARKER
- If a here-string was intended, inline the value directly as a normal argument instead
Example fix
# before respond <<<EOF # after respond <<EOF
Defensive patterns
Strategy: validation
Validate before calling
if strings.Contains(line, "<<<") {
return fmt.Errorf("three-angle heredoc not supported: %q", line)
} Prevention
- Use exactly two '<' for heredocs
- Don't paste shell here-strings into Caddyfiles
When it happens
Trigger: A Caddyfile line contains '<<<' before the marker on the opening heredoc line; the lexer detects val[:3] == "<<<" when the newline arrives.
Common situations: Copy-pasting shell scripts or examples that use <<< into a Caddyfile directive, or muscle memory from bash here-strings.
Related errors
- heredoc marker on line #
- incomplete heredoc <<
- mismatched leading whitespace in heredoc <<
- missing opening heredoc marker on line #
- a cycle of imports exists between
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/60e908f6c94d9c1f.
Report an issue: GitHub.
Appendix: source
Thrown at caddyconfig/caddyfile/lexer.go:163
}
// skip CR, we only care about LF
if ch == '\r' {
continue
}
// after hitting a newline, we know that the heredoc marker
// is the characters after the two << and the newline.
// we reset the val because the heredoc is syntax we don't
// want to keep.
if ch == '\n' {
if len(val) == 2 {
return false, fmt.Errorf("missing opening heredoc marker on line #%d; must contain only alphanumeric characters, dashes and underscores; got empty string", l.line)
}
// check if there's too many <
if string(val[:3]) == "<<<" {
return false, fmt.Errorf("too many '<' for heredoc on line #%d; only use two, for example <<END", l.line)
}
heredocMarker = string(val[2:])
if !heredocMarkerRegexp.Match([]byte(heredocMarker)) {
return false, fmt.Errorf("heredoc marker on line #%d must contain only alphanumeric characters, dashes and underscores; got '%s'", l.line, heredocMarker)
}
inHeredoc = true
l.skippedLines++
val = nil
continue
}
val = append(val, ch)
continue
}
// if we're in a heredoc, all characters are read as-is
if inHeredoc {View on GitHub (pinned to 50e54ee279)