From c1907df2edbaa7f7ab8b4f13843bb8ee1a618e4a Mon Sep 17 00:00:00 2001 From: TowyTowy <85077986+TowyTowy@users.noreply.github.com> Date: Sun, 12 Jul 2026 01:16:34 +0200 Subject: [PATCH] intercept: fix misleading handle_response error for extra matcher args (#7871) Same obsolete two-argument check as the reverse_proxy one removed in #7869: it referenced the long-removed inline status-code-replacement syntax and pointed users at replace_status even when no status replacement was involved. The generic check now rejects all excess-argument cases with an accurate message. Co-authored-by: Claude Fable 5 --- ...ercept_handle_response_too_many_args.caddyfiletest | 11 +++++++++++ modules/caddyhttp/intercept/intercept.go | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 caddytest/integration/caddyfile_adapt/intercept_handle_response_too_many_args.caddyfiletest diff --git a/caddytest/integration/caddyfile_adapt/intercept_handle_response_too_many_args.caddyfiletest b/caddytest/integration/caddyfile_adapt/intercept_handle_response_too_many_args.caddyfiletest new file mode 100644 index 000000000..ba3ef5655 --- /dev/null +++ b/caddytest/integration/caddyfile_adapt/intercept_handle_response_too_many_args.caddyfiletest @@ -0,0 +1,11 @@ +localhost:8884 { + intercept { + handle_response header Foo { + respond "handled" + } + } + respond "hello" +} + +---------- +parsing caddyfile tokens for 'intercept': too many arguments for 'handle_response': only a single response matcher name is allowed, but got: [header Foo] diff --git a/modules/caddyhttp/intercept/intercept.go b/modules/caddyhttp/intercept/intercept.go index f0deb1b26..fc37be05b 100644 --- a/modules/caddyhttp/intercept/intercept.go +++ b/modules/caddyhttp/intercept/intercept.go @@ -303,13 +303,8 @@ func (i *Intercept) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) erro d.Next() args := d.RemainingArgs() - // TODO: Remove this check at some point in the future - if len(args) == 2 { - return d.Errf("configuring 'handle_response' for status code replacement is no longer supported. Use 'replace_status' instead.") - } - if len(args) > 1 { - return d.Errf("too many arguments for 'handle_response': %s", args) + return d.Errf("too many arguments for 'handle_response': only a single response matcher name is allowed, but got: %s", args) } var matcher *caddyhttp.ResponseMatcher