rossoctl / rossoctl/cortex

Parity tests: Handle request-body mutation

Open
#938 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13
Forks
40
Avg merge
12h 17m
Merged PRs (30d)
156

Description

The parity suite doesn't exercise plugin-driven body mutation. A plugin that rewrites the request body via pctx.SetBody (declaring WritesRequestBody: true) has its output travel to the upstream through completely different code paths on each listener — Envoy's BodyMutation proto message for extproc, direct Request.Body replacement for the proxies.

Why it matters

  • A rewrite that lands on the wire on one listener and gets dropped on the other is silent — the pipeline plugin sees success, upstream sees the original bytes, only one deployment shape misbehaves.
  • Header rewrites (Content-Length, Content-Type) accompanying a body change follow a separate encoding path per listener and can drift independently from the body itself.
  • The tool-prune plugin depends on this exact contract in production; without a parity fixture, its behavior across deployment shapes is asserted only by end-to-end tests.

Fix

Add a mutateRequestBody []byte knob to spyConfig. When set, spyPlugin.OnRequest calls pctx.SetBody(cfg.mutateRequestBody) and the fixture:

  • Declares WritesRequestBody: true in Capabilities.
  • Asserts the upstream (httptest.Server on the proxy path, mock stream response on extproc) receives the mutated bytes verbatim on both listeners.
  • Asserts the mutated Content-Length reaches upstream headers consistently.

Depends on the ReadsBody fixture landing first (#937) since request-body mutation shares the two-phase handshake plumbing.

Follow-up from #935.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the parity suite's spyConfig and spyPlugin.OnRequest entry points, then inspect the existing ReadsBody fixture and dependency on #937. Add coverage for SetBody with WritesRequestBody enabled, verifying that both listener paths deliver the mutated bytes and matching Content-Length to their upstreams.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.