Skip to content

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Oct 17, 2025

Description

This fixes a bug in the per-backend header mutator where the previous mutation in retry case causes incorrect header presence, absence or incorrect header values.

Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake mathetake changed the title fix: reset previously set/removed values in header mutation fix: reset previously set/removed values in per-backend header mutation Oct 17, 2025
testUpstreamAzureBackend,
testUpstreamGCPVertexAIBackend,
testUpstreamGCPAnthropicAIBackend,
// TODO: this shouldn't be needed. The previous per-backend headers shouldn't affect the subsequent retries.
Copy link
Member Author

@mathetake mathetake Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO summarizes what was happening with the bug being fixed here

// Add debug logging for extproc.
"--component-log-level", "ext_proc:trace,http:debug,connection:debug",
// Add debug logging for http.
"--component-log-level", "http:debug",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ext_proc trace is just a noise as well as connection stuff as well

@mathetake mathetake marked this pull request as ready for review October 17, 2025 17:00
@mathetake mathetake requested a review from a team as a code owner October 17, 2025 17:00
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
require.Equal(t, "custom-value", headers["x-custom"])
})

t.Run("header mutations restored on retry", func(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this simply re-tests the headermutator internal so it's overlapping with the tests there, hence removed it.

require.Equal(t, "custom-value", headers["x-custom"])
})

t.Run("header mutations restored on retry", func(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 85.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.43%. Comparing base (7b753b0) to head (aae64fd).

Files with missing lines Patch % Lines
internal/extproc/headermutator/header_mutator.go 87.87% 2 Missing and 2 partials ⚠️
tests/internal/testenvironment/test_environment.go 0.00% 2 Missing ⚠️

❌ Your project status has failed because the head coverage (77.43%) is below the target coverage (86.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1387      +/-   ##
==========================================
+ Coverage   77.42%   77.43%   +0.01%     
==========================================
  Files         131      131              
  Lines       16543    16569      +26     
==========================================
+ Hits        12809    12831      +22     
- Misses       3099     3101       +2     
- Partials      635      637       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake
Copy link
Member Author

ok ready to go!

Copy link
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good to me

@johnugeorge
Copy link
Contributor

Cc @siddharth1036

// 1. Remove any headers that were added in the previous attempt (not part of original headers and not being set now).
// 2. Restore any original headers that were modified in the previous attempt (and not being set now).
for key := range headers {
key = strings.ToLower(key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just TOL, should we merge this loop and the loop over original headers? If I understand this loop (if no removals or additions) will make headers equal to orignalHeaders. Should we start with headers = originalHeaders and go ahead with remaining mutations?
Initially I skipped this to avoid any header that was already added and was different from original header before entering mutation but as we are making them same now just wondering if extra loop is required

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it in a follow up later

@mathetake mathetake merged commit a9b0cd6 into main Oct 20, 2025
31 checks passed
@mathetake mathetake deleted the headermutatorfix branch October 20, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants