Skip to content

[PR] fix: replace egress plugin headers case-insensitively - #6606

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_egress-header-replacement
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_egress-header-replacement

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #6605

Problem

A plugin returning Authorization does not replace an existing lowercase authorization key. The case-sensitive object merge leaves both entries, and Fetch combines the original and replacement values. The same problem affects other header fields and sequential plugins.

The new real HTTP test sends a model request through startServer with an actual local ESM egress plugin. On unchanged master, its upstream sees Bearer original-test-key, Bearer replacement-test-key and the request returns 401. With this change, the upstream sees only the replacement placeholder credential and returns 200.

Change

Use the existing case-insensitive deletion helper before setting each returned header value. This preserves the plugin's chosen spelling and exact value while extending the existing last-update-wins behavior across casing variants. It also retains case-insensitive deletion and unrelated headers.

This is a two-line correction in the shared egress runner. Direct header mutation, body rewriting, timeout behavior, signing policy, plugin ordering and configuration remain unchanged.

Validation

  • Nine new cases on unchanged master: 6 fail, 3 controls pass.
  • Fixed related suites: 33 pass, 0 fail across egress-header-replacement, egress-transforms and issue5688-egress-wiring.
  • Coverage includes both casing directions, duplicate existing names, duplicate names in a returned patch, successive plugins, case-insensitive deletion, explicit comma-separated values, unconfigured Buffer identity, and the real HTTP authentication outcome.
  • npm run typecheck, npm run build, npm run check:unused-exports, npm run check:test-import-graph and git diff --check pass.

Baseline: e1f31ad9d5b47500362699a9867819b861c7de96 (0.1.213), Node v24.22.1, repository test/storage preloads. Full-suite validation remains with hosted CI on this head.

Prior work

All-state egress/header/casing searches and contributor history found no existing fix. #6068 introduces this pipeline; #6117 concerns Trae protocol support. My earlier #6149 fixes throttle identity and #6563 fixes Fetch RequestInit normalization, at separate boundaries.

Suggested triage: bug, p2, scope/wiring; Topic N — server-side miscellaneous.

@ranxianglei ranxianglei changed the title fix: replace egress plugin headers case-insensitively [PR] fix: replace egress plugin headers case-insensitively Nov 13, 2026
@ranxianglei
ranxianglei merged commit 08423b1 into ranxianglei:master Nov 14, 2026
44 of 48 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit 08423b111c2 (Merge Afloat16/2026-11-13_egress-header-replacement (PR #6606)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6605 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

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.

Egress plugin header replacement retains the old value when field casing differs

2 participants