Skip to content

Commit 46d4150

Browse files
authored
test(codex): follow #2398 on the oversized pool-retry 400 body (#2404)
#2398 stopped relaying attacker-controlled error prefixes: an oversized upstream body now becomes #452's bounded status-only JSON instead of being passed through. It added "oversized passthrough errors become bounded status-only JSON" to assert exactly that, but left this test asserting the opposite -- that the original 65 KiB body comes back verbatim. Both were green on their own branches and only collide on dev, because CI tests the PR head rather than the merge result. The invariant this test exists for is unchanged and still asserted: an oversized 400 does not authorize a pool retry, so exactly one account is dispatched and neither is marked unhealthy. Only the body expectation moves, and it now also asserts the hostile suffix does not reach the client.
1 parent c9d10ed commit 46d4150

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎tests/server-auth.test.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,11 +2957,29 @@ describe("server local API auth", () => {
29572957
}
29582958
}, { timeout: SERVER_BUDGET_MS });
29592959

2960+
// #2398 changed what the caller sees here, and this test had to move with it.
2961+
//
2962+
// The invariant this test exists for is unchanged and still asserted: an oversized 400
2963+
// must NOT authorize a pool retry, so exactly one account is dispatched and neither
2964+
// account is marked unhealthy. What changed is the body. Relaying 65 KiB of
2965+
// attacker-controlled bytes back to the client is precisely what #2398 stopped, so the
2966+
// caller now gets #452's bounded status-only JSON instead of the original prefix
2967+
// (pinned from the other side by "oversized passthrough errors become bounded
2968+
// status-only JSON" in tests/issue-452-empty-503.test.ts).
2969+
//
2970+
// The upstream's own headers still survive, which is what keeps pool-retry diagnostics
2971+
// honest — that part is still checked below.
29602972
test("oversized 400 body never authorizes a pool retry", async () => {
2961-
const body = `${unsupportedModelBody()}${"x".repeat(65_536)}`;
2973+
const hostileSuffix = "x".repeat(65_536);
2974+
const body = `${unsupportedModelBody()}${hostileSuffix}`;
29622975
const harness = await startPoolRetryHarness(() => rejectionResponse(body));
29632976
try {
2964-
await expectOriginal400(await harness.request(), body);
2977+
const response = await harness.request();
2978+
expect(response.status).toBe(400);
2979+
const text = await response.text();
2980+
expect(text).not.toContain(hostileSuffix);
2981+
expect(text.length).toBeLessThan(1_024);
2982+
29652983
expect(harness.dispatches).toEqual(["acct-pool-a"]);
29662984
expect(getCodexUpstreamHealth("pool-a")).toBeNull();
29672985
expect(getCodexUpstreamHealth("pool-b")).toBeNull();

0 commit comments

Comments
 (0)