Repository navigation
Conversation
ImmediateResponseWriter.AppendHeader did not append. When a filter added the same header more than once to an immediate response, for example two set-cookie headers on a redirect, Envoy kept only the last one. Why: AppendHeader set only append_action to APPEND_IF_EXISTS_OR_ADD on the HeaderValueOption. That is the enum's zero value, so in proto3 it is never sent and Envoy cannot tell it apart from "not set". Envoy's ext_proc then falls back to the deprecated append field, which the HeaderMutation docs say "defaults to false when used in this message", and false means overwrite. So every header but the last with that name was dropped. CommonResponseWriter already handles this by also setting the deprecated Append field to true for APPEND_IF_EXISTS_OR_ADD. ImmediateResponseWriter now does the same. SetHeader is unchanged and still overwrites. How it was found: the China data consent redirect in ingress-sidecar sends a 302 with two set-cookie headers, one setting gyg_cn_data_consent_version and one expiring gyg_cn_data_consent. Its integration test, which runs through a real Envoy (istio proxyv2 1.31.0), only saw the second cookie. In production, users who consented would have had no version cookie and would have been sent back to the consent page in a loop. ingress-sidecar works around this for now with withEnvoyAppend in internal/pkg/filters/redirects/redirects.go, which can be removed once it uses a version of this module with this fix. The new test checks that AppendHeader sets Append to true and that SetHeader leaves it unset. The nolint:staticcheck lines are needed because Append is deprecated, but it is still the only way to make Envoy's ext_proc append. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
cainelli
approved these changes
Nov 16, 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.
ImmediateResponseWriter.AppendHeader did not append. When a filter added the same header more than once to an immediate response, for example two set-cookie headers on a redirect, Envoy kept only the last one.
Why: AppendHeader set only append_action to APPEND_IF_EXISTS_OR_ADD on the HeaderValueOption. That is the enum's zero value, so in proto3 it is never sent and Envoy cannot tell it apart from "not set". Envoy's ext_proc then falls back to the deprecated append field, which the HeaderMutation docs say "defaults to false when used in this message", and false means overwrite. So every header but the last with that name was dropped.
CommonResponseWriter already handles this by also setting the deprecated Append field to true for APPEND_IF_EXISTS_OR_ADD. ImmediateResponseWriter now does the same. SetHeader is unchanged and still overwrites.
How it was found: the China data consent redirect in ingress-sidecar sends a 302 with two set-cookie headers, one setting gyg_cn_data_consent_version and one expiring gyg_cn_data_consent. Its integration test, which runs through a real Envoy (istio proxyv2 1.31.0), only saw the second cookie. In production, users who consented would have had no version cookie and would have been sent back to the consent page in a loop. ingress-sidecar works around this for now with withEnvoyAppend in internal/pkg/filters/redirects/redirects.go, which can be removed once it uses a version of this module with this fix.
The new test checks that AppendHeader sets Append to true and that SetHeader leaves it unset. The nolint:staticcheck lines are needed because Append is deprecated, but it is still the only way to make Envoy's ext_proc append.