You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
respond blanks literal braces in header values (unknown placeholders) #8013
sends X-Json empty, and X-Lit arrives as value--kept, bcs the whole unrecognized brace span gets swallowed
the body on the same handler already uses repl.ReplaceKnown (that is why JSON bodies survive), and the header handler was switched to ReplaceKnown in #4880 after the same class of report in #4418, so respond headers look like the last site still on ReplaceAll
$ cat Caddyfile-test
:8977 {
respond {
header X-Json {"key":"value"}
header X-Lit value-{unknown}-kept
}
}
$ ./caddy adapt -a caddyfile --config Caddyfile-test
Error: parsing caddyfile tokens for 'respond': wrong argument count or unexpected line ending after 'respond', at Caddyfile-test:2
I'm not sure if replacing repl.ReplaceAll with repl.ReplaceKnown is a good idea in more and more places (other PRs, in particular #8008 for request_body) as it could break existing configurations where placeholders derived from e.g. request headers are preferred to be empty rather than the placeholder configuration itself. I understand that for JSON it's more convenient, but the opening { can also be escaped with \{ if i remember @francislavoie correctly (caddyserver/website#468) to avoid replacing at all.
good catch on the caddyfile snippet @steffenbusch, you are right that respond has no header subdirective so that example only works in the JSON config where static_response.headers lives, the go test on master is the actual repro, my bad for the confusing snippet
on ReplaceKnown vs ReplaceAll the direction was already set by mholt in #7021 and the maintainers applied it themselves, #4880 switched the header directive back in 2022 after #4418 reported the same blanking, and #8003 plus #8014 landed the same way for health and respond headers
the blanking of unknown {...} is exactly the bug both reports are about, so expanding only known placeholders keeps literal text like json working without escapes while { still exists for the rare case where you want a known placeholder name as literal text
the concern about configs that relied on the blanking is fair though, that call belongs to the maintainers, #8008 (request body) and #8017 (basic auth) are open for the remaining sites so let's see what they prefer there
Activity
steffenbusch commentedon Sep 13, 2026
Hi @steadytao, @hktitof
Just a note that the
responddirective in Caddyfile does not even haveheadersub-directives - the JSON config has https://caddyserver.com/docs/json/apps/http/servers/routes/handle/static_responseI'm not sure if replacing
repl.ReplaceAllwithrepl.ReplaceKnownis a good idea in more and more places (other PRs, in particular #8008 forrequest_body) as it could break existing configurations where placeholders derived from e.g. request headers are preferred to be empty rather than the placeholder configuration itself. I understand that for JSON it's more convenient, but the opening{can also be escaped with\{if i remember @francislavoie correctly (caddyserver/website#468) to avoid replacing at all.hktitof commentedon Sep 13, 2026
good catch on the caddyfile snippet @steffenbusch, you are right that respond has no header subdirective so that example only works in the JSON config where static_response.headers lives, the go test on master is the actual repro, my bad for the confusing snippet
on ReplaceKnown vs ReplaceAll the direction was already set by mholt in #7021 and the maintainers applied it themselves, #4880 switched the header directive back in 2022 after #4418 reported the same blanking, and #8003 plus #8014 landed the same way for health and respond headers
the blanking of unknown {...} is exactly the bug both reports are about, so expanding only known placeholders keeps literal text like json working without escapes while { still exists for the rare case where you want a known placeholder name as literal text
the concern about configs that relied on the blanking is fair though, that call belongs to the maintainers, #8008 (request body) and #8017 (basic auth) are open for the remaining sites so let's see what they prefer there