Repository navigation
reverseproxy: fix misleading handle_response error for extra matcher args - #7869
Merged
francislavoie merged 1 commit intoJul 10, 2026
Merged
francislavoie merged 1 commit into
francislavoie merged 1 commit into
Conversation
…args Passing more than one argument to handle_response (e.g. 'handle_response header Foo') hit an obsolete check for the removed inline status-code-replacement syntax and produced a confusing error telling the user to use 'replace_status' instead. Drop that obsolete check and reject any argument count greater than one with an accurate message stating that only a single named response matcher is allowed. Add a Caddyfile adapt test for the reported case. Fixes caddyserver#6529 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
francislavoie
approved these changes
Jul 10, 2026
francislavoie
left a comment
Member
There was a problem hiding this comment.
Thanks, yep that looks right to me.
francislavoie
enabled auto-merge (squash)
July 10, 2026 05:36
steadytao
pushed a commit
that referenced
this pull request
Jul 11, 2026
#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 was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6529
Per @steadytao's go-ahead on the issue, this implements exactly the fix @francislavoie specced in his review of #7709: reject more than a single argument to
handle_response, and stop referencingreplace_statusin the error message, stating instead that only a single response matcher name token is allowed.Previously,
handle_response header Foo { ... }tripped an obsolete two-argument check (left over from the long-removed inline status-code-replacement syntax, marked// TODO: Remove this check at some point in the future) and confusingly told the user to usereplace_statuseven though no status replacement was involved.Changes:
len(args) == 2special case and itsreplace_statusexplanation.len(args) > 1check now covers all excess-argument cases with an accurate message:too many arguments for 'handle_response': only a single response matcher name is allowed, but got: [header Foo].reverse_proxy_handle_response_too_many_args.caddyfiletest) for the exact case reported in Including matcher in 'handle_response' line has confusing error #6529, following the existing error-asserting adapt test convention. It fails on current master (old misleading message) and passes with this change.This intentionally supersedes #7709, which has been idle and took a different direction than the reviewed suggestion — thanks to @suryaanshah for the earlier effort there. Note the same obsolete check also exists in the
interceptdirective (modules/caddyhttp/intercept/intercept.go); left untouched here to keep this PR focused on the reported case, happy to follow up separately if desired.go test ./caddytest/integration/ -run TestCaddyfileAdaptToJSONandgo test ./modules/caddyhttp/reverseproxy/both pass; gofmt clean.Assistance Disclosure
This change was implemented with the assistance of Claude (Anthropic's LLM) via Claude Code: it drafted the code change and the adapt test under my direction, following the exact approach specified by the maintainers in #6529 / the #7709 review. I have read, fully understand, and take responsibility for every line, and verified the fix with a fail-before/pass-after test run.