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 <noreply@anthropic.com>
This commit is contained in:
TowyTowy
2026-07-12 01:16:34 +02:00
committed by GitHub
parent c6180a0852
commit c1907df2ed
2 changed files with 12 additions and 6 deletions

View File

@@ -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]

View File

@@ -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