From 152b8e1b52989004e289b4bbb527a162e5000804 Mon Sep 17 00:00:00 2001 From: Mark Nottingham Date: Tue, 3 Nov 2026 18:00:54 +1100 Subject: [PATCH] Fail, don't crash, when a request the test expects never reaches the origin checkServerRequests reads serverRequest.request_headers for expected_request_headers and expected_request_headers_missing without checking that the origin saw the request. If the cache answers it from its own store, serverState has no entry and the check throws a TypeError ("Cannot read properties of undefined (reading 'request_headers')") instead of reporting a result. conditional-etag-vary-headers-mismatch hits this with a cache that ignores Vary: request 2 is served from cache, so the origin never sees it. Assert that the request was sent, as the validating-header path already does. Both cases fail, since expecting a header to be absent still implies a request was made. Checked against a URL-keyed proxy that ignores Vary: the test now reports "request 2 wasn't sent to server" rather than the TypeError. Co-Authored-By: Claude Sonnet 5.5 --- test-engine/client/test.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-engine/client/test.mjs b/test-engine/client/test.mjs index 9d2fb97..0df16ab 100644 --- a/test-engine/client/test.mjs +++ b/test-engine/client/test.mjs @@ -335,6 +335,7 @@ function checkServerRequests (requests, responses, serverState) { }) if ('expected_request_headers' in reqConfig) { const reqPresentSetup = setupCheck(reqConfig, 'expected_request_headers') + assert(reqPresentSetup, typeof (serverRequest) !== 'undefined', `request ${reqNum} wasn't sent to server`) reqConfig.expected_request_headers.forEach(header => { if (typeof header === 'string') { const headerName = header.toLowerCase() @@ -349,6 +350,7 @@ function checkServerRequests (requests, responses, serverState) { } if ('expected_request_headers_missing' in reqConfig) { const reqmPresentSetup = setupCheck(reqConfig, 'expected_request_headers_missing') + assert(reqmPresentSetup, typeof (serverRequest) !== 'undefined', `request ${reqNum} wasn't sent to server`) reqConfig.expected_request_headers_missing.forEach(header => { if (typeof header === 'string') { const headerName = header.toLowerCase()