Skip to content

fix: allow x-ai-eg-model to be overridden via headerMutation#1977

Open
kimjihoon3106 wants to merge 1 commit into
envoyproxy:mainfrom
kimjihoon3106:fix/issue-1872-model-header-mutation
Open

fix: allow x-ai-eg-model to be overridden via headerMutation#1977
kimjihoon3106 wants to merge 1 commit into
envoyproxy:mainfrom
kimjihoon3106:fix/issue-1872-model-header-mutation

Conversation

@kimjihoon3106
Copy link
Copy Markdown

Fixes #1872

Description

shouldIgnoreHeader was silently dropping all x-ai-eg-* headers from
headerMutation.set, including the user-facing x-ai-eg-model header.
This made it impossible to override the model name forwarded to the backend
via headerMutation, even though x-ai-eg-model is a documented routing
header that users are expected to control.

This commit adds an explicit exception for ModelNameHeaderKeyDefault
(x-ai-eg-model) in shouldIgnoreHeader, allowing it to be set via
headerMutation while keeping all other internal x-ai-eg-* headers protected.

Related Issues/PRs (if applicable)

Fixes #1872

Special notes for reviewers (if applicable)

Only ModelNameHeaderKeyDefault (x-ai-eg-model) is exempted from the
ignore list. All other x-ai-eg-* headers remain blocked. A regression
test and a guard test are included to cover both behaviors.

Note: I identified this bug by reading through the codebase and traced it
to shouldIgnoreHeader in header_mutator.go. I used Claude (AI) as a
coding assistant during implementation. I fully understand and own all
changes submitted in this PR.

The shouldIgnoreHeader function was blocking all x-ai-eg-* headers from
being set or removed via the headerMutation API. This prevented users from
overriding the x-ai-eg-model header to control the model name forwarded to
the backend.

x-ai-eg-model is a documented user-facing header (ModelNameHeaderKeyDefault)
that is used in routing rules and legitimately needs to be overridable at the
backend level via headerMutation.

This change adds an exception for ModelNameHeaderKeyDefault in
shouldIgnoreHeader, while keeping all other x-ai-eg-* internal headers
protected.

Fixes envoyproxy#1872
@kimjihoon3106 kimjihoon3106 requested a review from a team as a code owner March 20, 2026 08:08
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header value of x-ai-eg-model is not changed when headerMutation is set

1 participant