Skip to content

[2.11.2 Regression] {block} is ignored when imported from a separate file #7557

@msladek

Description

@msladek

Issue Details

Description
When importing a snippet from a separate file that contains a directive wrapping a {block} placeholder (such as reverse_proxy), Caddy v2.11 silently ignores the provided block during the import.

This bug only seems to happen if the snippet is in a separate file.

Steps to reproduce
./Caddyfile

{
  admin off
  auto_https off
}

import snippets

:8080 {
  import test {
    this_is_nonsense
  }
}

./snippets

(test) {
  reverse_proxy {
    {block}
  }
}

run

docker run --rm -p 8080:8080 -v "$PWD:/etc/caddy:ro" caddy:2.11 caddy run --config /etc/caddy/Caddyfile

Expected Behavior (Caddy v2.10)
In Caddy v2.10, the {block} is injected correctly. The parser evaluates the contents, sees the invalid this_is_nonsense subdirective inside reverse_proxy, and rightfully refuses to start:

$ docker run --rm -p 8080:8080 -v "$PWD:/etc/caddy:ro" caddy:2.10 caddy run --config /etc/caddy/Caddyfile
Error: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': unrecognized subdirective this_is_nonsense

Actual Behavior (Caddy v2.11)
In Caddy v2.11, the {block} is entirely ignored. The reverse_proxy directive evaluates as empty, so Caddy happily starts up with no errors.

$ curl -i http://127.0.0.1:8080/
HTTP/1.1 503 Service Unavailable
Server: Caddy
Date: Mon, 09 Mar 2026 20:19:33 GMT
Content-Length: 0

Assistance Disclosure

AI used

If AI was used, describe the extent to which it was used.

ChatGPT improved the issue description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions