fix(router): add Vary to SkippedHeaders to prevent duplicate header#2737
fix(router): add Vary to SkippedHeaders to prevent duplicate header#2737vickyshaw29 wants to merge 5 commits intowundergraph:mainfrom
Conversation
WalkthroughAdded Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @vickyshaw29, can you add a test? Both unit + integraion would be great! |
|
Added both in b546c6f, unit test for isIgnoredHeader and extended the existing integration test for ignored response headers. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
| func TestIsIgnoredHeader_Vary(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| assert.True(t, isIgnoredHeader("Vary")) | ||
| assert.True(t, isIgnoredHeader("vary")) | ||
| assert.False(t, isIgnoredHeader("X-Custom-Header")) | ||
| } |
There was a problem hiding this comment.
I stand corrected, this is a useless test, integration looks good though.
There was a problem hiding this comment.
Removed the unit test, kept the integration one
There was a problem hiding this comment.
🧹 Nitpick comments (1)
router-tests/protocol/header_propagation_test.go (1)
120-124: Integration coverage for Vary is on point.The propagate rule + subgraph-side
Vary: Origininjection + client-sideNotEqualassertion mirrors the existing pattern forContent-Type/Content-Encoding/Connectionand correctly exercises the fix for#2614.Optional nit (non-blocking, and consistent with the surrounding cases so feel free to ignore):
require.NotEqual(t, "Origin", vary, ...)would still pass if the router forwarded, say,Origin, Accept-Encoding. A stricter check would berequire.NotContains(t, vary, "Origin")or assertingVaryis absent from the subgraph-injected value entirely. Same caveat applies to the neighboring ignored-header assertions, so changing justVarywould make the tests inconsistent.Also applies to: 142-142, 165-167
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router-tests/protocol/header_propagation_test.go` around lines 120 - 124, The Vary propagation test uses require.NotEqual which would still pass if the router forwarded a compound header like "Origin, Accept-Encoding"; update the assertion(s) associated with the propagate rule for Named "Vary" (the case using config.HeaderRuleOperationPropagate and config.ResponseHeaderRuleAlgorithmLastWrite) to use a stricter check such as require.NotContains(t, vary, "Origin") or assert that the Vary header does not contain "Origin" (or is entirely absent) instead of NotEqual; apply the same change to the other occurrences that assert Vary in this test to keep consistency with the neighboring ignored-header assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@router-tests/protocol/header_propagation_test.go`:
- Around line 120-124: The Vary propagation test uses require.NotEqual which
would still pass if the router forwarded a compound header like "Origin,
Accept-Encoding"; update the assertion(s) associated with the propagate rule for
Named "Vary" (the case using config.HeaderRuleOperationPropagate and
config.ResponseHeaderRuleAlgorithmLastWrite) to use a stricter check such as
require.NotContains(t, vary, "Origin") or assert that the Vary header does not
contain "Origin" (or is entirely absent) instead of NotEqual; apply the same
change to the other occurrences that assert Vary in this test to keep
consistency with the neighboring ignored-header assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fd08a859-aa1d-4e80-9185-1674c572bf8e
📒 Files selected for processing (2)
router-tests/protocol/header_propagation_test.gorouter/core/header_rule_engine_test.go
Fixes #2614
gzhttp already adds Vary: Accept-Encoding to every compressed response. The same header coming from subgraphs gets propagated again through headerPropagationWriter, causing duplicates. This just adds Vary to the SkippedHeaders map so it doesn't get forwarded.
Summary by CodeRabbit