From d4b999650ff67adf41fdbd1a9bdc8093dfb6a364 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 03:48:52 +0000 Subject: [PATCH] Assert 412 precondition content-type and length headers Co-authored-by: Theo Browne --- apps/t3/scripts/smoke-test.mjs | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index 1a648f0648..bd5f29c75e 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -352,6 +352,21 @@ async function main() { `Smoke test failed: expected If-Match mismatch status 412, received ${ifMatchMismatchAsset.status}.`, ); } + if ((ifMatchMismatchAsset.headers.get("content-type") ?? "").toLowerCase() !== "text/plain; charset=utf-8") { + throw new Error( + `Smoke test failed: expected plain-text content-type on If-Match mismatch response, got ${String( + ifMatchMismatchAsset.headers.get("content-type"), + )}.`, + ); + } + const ifMatchMismatchContentLength = Number(ifMatchMismatchAsset.headers.get("content-length") ?? "0"); + if (!Number.isFinite(ifMatchMismatchContentLength) || ifMatchMismatchContentLength <= 0) { + throw new Error( + `Smoke test failed: expected positive content-length on If-Match mismatch response, got ${String( + ifMatchMismatchAsset.headers.get("content-length"), + )}.`, + ); + } if ((ifMatchMismatchAsset.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") { throw new Error("Smoke test failed: expected cache-control=no-store on If-Match mismatch response."); } @@ -513,6 +528,26 @@ async function main() { `Smoke test failed: expected HEAD If-Match mismatch status 412, received ${ifMatchMismatchHeadAsset.status}.`, ); } + if ( + (ifMatchMismatchHeadAsset.headers.get("content-type") ?? "").toLowerCase() !== + "text/plain; charset=utf-8" + ) { + throw new Error( + `Smoke test failed: expected plain-text content-type on HEAD If-Match mismatch response, got ${String( + ifMatchMismatchHeadAsset.headers.get("content-type"), + )}.`, + ); + } + const ifMatchMismatchHeadContentLength = Number( + ifMatchMismatchHeadAsset.headers.get("content-length") ?? "0", + ); + if (!Number.isFinite(ifMatchMismatchHeadContentLength) || ifMatchMismatchHeadContentLength <= 0) { + throw new Error( + `Smoke test failed: expected positive content-length on HEAD If-Match mismatch response, got ${String( + ifMatchMismatchHeadAsset.headers.get("content-length"), + )}.`, + ); + } if ((ifMatchMismatchHeadAsset.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") { throw new Error( "Smoke test failed: expected cache-control=no-store on HEAD If-Match mismatch response.",