Repository navigation
Conversation
…data Since caddyserver#7569 every lb_retry_match set with an expression is evaluated against upstream responses. An expression that only tests the request, such as {http.request.method} == "POST", then matched every successful response: the request was sent again to the next upstreams and the client got a 502 once retries ran out. Only treat expressions referencing {rp.*} placeholders as response conditions.
steadytao
requested changes
Oct 8, 2026
steadytao
requested changes
Oct 9, 2026
The expression matcher records the placeholder names its checked CEL expression reads, so retry_match finds direct ph() calls and ignores escaped placeholder text in string literals. A placeholder name only known at evaluation time counts as response data.
steadytao
requested changes
Oct 9, 2026
Only the header placeholders are matched by prefix now, and both upstream latency placeholders are listed. MatchExpression.Placeholders returns a copy, so callers cannot change the provisioned matcher.
steadytao
approved these changes
Oct 9, 2026
This was referenced Nov 3, 2026
NickCao
pushed a commit
to NickCao/caddy
that referenced
this pull request
Nov 4, 2026
…data (caddyserver#8168) * reverseproxy: Only retry responses for expressions that use response data Since caddyserver#7569 every lb_retry_match set with an expression is evaluated against upstream responses. An expression that only tests the request, such as {http.request.method} == "POST", then matched every successful response: the request was sent again to the next upstreams and the client got a 502 once retries ran out. Only treat expressions referencing {rp.*} placeholders as response conditions. * reverseproxy: Only count placeholders set from the response as response data * reverseproxy: Read response placeholders from the checked expression The expression matcher records the placeholder names its checked CEL expression reads, so retry_match finds direct ph() calls and ignores escaped placeholder text in string literals. A placeholder name only known at evaluation time counts as response data. * reverseproxy: Match response placeholder names exactly Only the header placeholders are matched by prefix now, and both upstream latency placeholders are listed. MatchExpression.Placeholders returns a copy, so callers cannot change the provisioned matcher. (cherry picked from commit 7c74563)
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.
Closes #8166
Since #7569 every
lb_retry_matchset containing anexpressionis evaluated against the upstream response. An expression that only tests the request, like{http.request.method} == "POST", matched every successful response, so the request was sent again to the next upstreams and the client got a 502 when retries ran out.Response retries now apply only to expressions that reference response placeholders (
{rp.*}, which the Caddyfile adapts to{http.reverse_proxy.*}). Other expressions are request conditions again, as before v2.11.3. All the examples from #7569 reference{rp.*}and behave as before.Test:
TestRequestOnlyExpressionDoesNotRetryResponsessends a POST through two healthy upstreams with that expression. Without the change it returns a 502 (ContentLength=7 with Body length 0on the retry); with it the upstream is hit once and the 200 body comes through.go test ./...passes, including the existing retry_match unit and integration tests.Manual check with the Caddyfile from the issue: v2.11.7 answers the POST with 502 after three upstream hits; with the change it returns the backend's 200 after one hit.
Assistance Disclosure
Claude Code (Claude Opus) helped write this patch and its test. I reviewed every line, and I ran the test before and after the change and the manual check above myself.