Skip to content

[PR] fix: isolate binary body drafts from failed egress plugins - #7044

Closed
Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_isolate-egress-buffer-drafts
Closed

Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_isolate-egress-buffer-drafts

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The egress runner hands a plugin the live outbound Buffer. A plugin can mutate it before throwing, returning an invalid result, or timing out. The fail-open path then returns the same reference with damaged bytes. A timed-out plugin can also corrupt a body after the runner has already returned it. This affects binary passthrough and Buffers produced by an earlier plugin.

Change

Give each matching plugin a private Buffer draft. Only a successful, valid returned body replaces the accepted body, matching the existing result contract. Strings retain their existing value semantics; empty, disabled and unmatched pipelines retain their no-op behavior. Successful header changes still commit independently of body replacement.

The isolation costs one linear Buffer copy per matching plugin that receives a Buffer. String-based JSON requests do not take that copy path.

Verification

  • Base: 301e1a5459a77d5578206927c8062a58381af642.
  • Ten new regressions: 9 fail / 1 passes on the base; the no-op/unmatched control already passes.
  • New and related egress suites: 51 tests passed. Coverage includes thrown, timed-out and invalid-result plugins; late mutations after a timeout; header-only successful returns; returning a modified draft; and a later failure after an earlier plugin produced a Buffer.
  • A real HTTP proxy sends a six-byte binary payload through a throwing plugin to a validating upstream. The base sends six zero bytes and receives HTTP 400; the fix preserves the exact payload and receives HTTP 200.
  • Full npm run typecheck, npm run build, and git diff --check: passed.
  • Codex preflight found the CLI and artifact but the configured upstream 127.0.0.1:8199 is unreachable; real four-phase host acceptance remains unrun.

Duplicate checks covered all states and Afloat16's history. #6608 explicitly isolated only headers and left Buffer/body handling unchanged; it does not prevent the byte corruption reproduced here. #6606 handles case-insensitive header replacement. The new change is limited to body ownership in the shared egress runner.

Fixes #7043

@ranxianglei ranxianglei changed the title fix: isolate binary body drafts from failed egress plugins [PR] fix: isolate binary body drafts from failed egress plugins Nov 17, 2026
Merge upstream master 6a641f3, including the architecture module-map and schedule-independent ranxianglei#2929 probe fixes.

Preserve the existing PR head and exact contribution patch. Validation of this refreshed head runs in upstream CI; no local test rerun is claimed.
@ranxianglei

Copy link
Copy Markdown
Owner

This fix is included verbatim (original commits and authorship preserved) in the merged batch PR #7074 — the changes are already on master. Closing to avoid a duplicate merge. 该修复已随批量 PR #7074 原样合入 master,为避免重复合并,关闭此 PR。

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.

Failed egress plugins can corrupt outbound binary bodies despite fail-open handling

2 participants