Import <args> slicing not working

1. The problem I’m having:

I am trying to use snippet + import to simplify my Caddyfile. I use wildcard certificate, so based on what I have read, I need to use handle. I found in the forums an example.

I am testing it out with respond, and respond works as expected when I

(sub) {
        @sub-{args[0]} host {args[0]}.{$HOSTNAME}
        handle @sub-{args[0]} {
                respond "{args[0]} {args[1]} {args[:]}"

Test import:

* {
    import sub heartbeat Caddy is up - subsnippet

returns heartbeat Caddy {args[:]}

2. Error messages and/or full log output:

According to the docs import (Caddyfile directive) — Caddy Documentation
{args[:]} should return all the arguments from version 2.7.0, but it does not work for me.
I have tried different slicings, but every time I use :, it does not parse. What am I doing wrong?

3. Caddy version:

/srv # caddy -v
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

Docker inside Debian 12 VM on Proxmox host. Geekom A5 computer.

b. Command:


FROM caddy:2.7.6-builder AS builder

RUN xcaddy build \
FROM caddy:2.7.6

COPY --from=builder /usr/bin/caddy /usr/bin/caddy


    # image: caddy:2
    # building own caddy to include duckdns
      context: ./build/caddy
      network: host
    restart: unless-stopped
      - 80:80
      - 443:443
      TZ: $TZ
      - ./build/caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./secrets/caddy/data:/data
      - ./secrets/caddy/config:/config

c. Service/unit/compose file:

see above

d. My complete Caddy config:

I will add a working config file later if needed.

5. Links to relevant resources:

A current limitation is that variadic style args can only be used as a single token, and not within another token. That’s because it may expand to multiple tokens.

If you need to use space-separated string inside another, then wrap it with quotes on your import line then use {args[2]} or whatever instead.